Rabbit-R1/switch port/java/sources/com/google/common/collect/Cut.java
2024-05-21 17:08:36 -04:00

470 lines
16 KiB
Java

package com.google.common.collect;
import com.google.common.base.Preconditions;
import com.google.common.primitives.Booleans;
import java.io.Serializable;
import java.lang.Comparable;
import java.util.NoSuchElementException;
import javax.annotation.CheckForNull;
/* JADX INFO: Access modifiers changed from: package-private */
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
private static final long serialVersionUID = 0;
final C endpoint;
/* JADX INFO: Access modifiers changed from: package-private */
public Cut<C> canonical(DiscreteDomain<C> discreteDomain) {
return this;
}
/* JADX INFO: Access modifiers changed from: package-private */
public abstract void describeAsLowerBound(StringBuilder sb);
/* JADX INFO: Access modifiers changed from: package-private */
public abstract void describeAsUpperBound(StringBuilder sb);
/* JADX INFO: Access modifiers changed from: package-private */
public C endpoint() {
return this.endpoint;
}
/* JADX INFO: Access modifiers changed from: package-private */
@CheckForNull
public abstract C greatestValueBelow(DiscreteDomain<C> discreteDomain);
public abstract int hashCode();
/* JADX INFO: Access modifiers changed from: package-private */
public abstract boolean isLessThan(C c);
/* JADX INFO: Access modifiers changed from: package-private */
@CheckForNull
public abstract C leastValueAbove(DiscreteDomain<C> discreteDomain);
/* JADX INFO: Access modifiers changed from: package-private */
public abstract BoundType typeAsLowerBound();
/* JADX INFO: Access modifiers changed from: package-private */
public abstract BoundType typeAsUpperBound();
/* JADX INFO: Access modifiers changed from: package-private */
public abstract Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain);
/* JADX INFO: Access modifiers changed from: package-private */
public abstract Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain);
Cut(C c) {
this.endpoint = c;
}
@Override // java.lang.Comparable
public int compareTo(Cut<C> cut) {
if (cut == belowAll()) {
return 1;
}
if (cut == aboveAll()) {
return -1;
}
int compareOrThrow = Range.compareOrThrow(this.endpoint, cut.endpoint);
return compareOrThrow != 0 ? compareOrThrow : Booleans.compare(this instanceof AboveValue, cut instanceof AboveValue);
}
public boolean equals(@CheckForNull Object obj) {
if (!(obj instanceof Cut)) {
return false;
}
try {
return compareTo((Cut) obj) == 0;
} catch (ClassCastException unused) {
return false;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <C extends Comparable> Cut<C> belowAll() {
return BelowAll.INSTANCE;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public static final class BelowAll extends Cut<Comparable<?>> {
private static final BelowAll INSTANCE = new BelowAll();
private static final long serialVersionUID = 0;
private Object readResolve() {
return INSTANCE;
}
@Override // com.google.common.collect.Cut, java.lang.Comparable
public int compareTo(Cut<Comparable<?>> cut) {
return cut == this ? 0 : -1;
}
@Override // com.google.common.collect.Cut
boolean isLessThan(Comparable<?> comparable) {
return true;
}
public String toString() {
return "-∞";
}
private BelowAll() {
super("");
}
@Override // com.google.common.collect.Cut
Comparable<?> endpoint() {
throw new IllegalStateException("range unbounded on this side");
}
@Override // com.google.common.collect.Cut
BoundType typeAsLowerBound() {
throw new IllegalStateException();
}
@Override // com.google.common.collect.Cut
BoundType typeAsUpperBound() {
throw new AssertionError("this statement should be unreachable");
}
@Override // com.google.common.collect.Cut
Cut<Comparable<?>> withLowerBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
throw new IllegalStateException();
}
@Override // com.google.common.collect.Cut
Cut<Comparable<?>> withUpperBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
throw new AssertionError("this statement should be unreachable");
}
@Override // com.google.common.collect.Cut
void describeAsLowerBound(StringBuilder sb) {
sb.append("(-∞");
}
@Override // com.google.common.collect.Cut
void describeAsUpperBound(StringBuilder sb) {
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
Comparable<?> leastValueAbove(DiscreteDomain<Comparable<?>> discreteDomain) {
return discreteDomain.minValue();
}
@Override // com.google.common.collect.Cut
Comparable<?> greatestValueBelow(DiscreteDomain<Comparable<?>> discreteDomain) {
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
Cut<Comparable<?>> canonical(DiscreteDomain<Comparable<?>> discreteDomain) {
try {
return Cut.belowValue(discreteDomain.minValue());
} catch (NoSuchElementException unused) {
return this;
}
}
@Override // com.google.common.collect.Cut
public int hashCode() {
return System.identityHashCode(this);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <C extends Comparable> Cut<C> aboveAll() {
return AboveAll.INSTANCE;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public static final class AboveAll extends Cut<Comparable<?>> {
private static final AboveAll INSTANCE = new AboveAll();
private static final long serialVersionUID = 0;
private Object readResolve() {
return INSTANCE;
}
@Override // com.google.common.collect.Cut, java.lang.Comparable
public int compareTo(Cut<Comparable<?>> cut) {
return cut == this ? 0 : 1;
}
@Override // com.google.common.collect.Cut
boolean isLessThan(Comparable<?> comparable) {
return false;
}
public String toString() {
return "+∞";
}
private AboveAll() {
super("");
}
@Override // com.google.common.collect.Cut
Comparable<?> endpoint() {
throw new IllegalStateException("range unbounded on this side");
}
@Override // com.google.common.collect.Cut
BoundType typeAsLowerBound() {
throw new AssertionError("this statement should be unreachable");
}
@Override // com.google.common.collect.Cut
BoundType typeAsUpperBound() {
throw new IllegalStateException();
}
@Override // com.google.common.collect.Cut
Cut<Comparable<?>> withLowerBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
throw new AssertionError("this statement should be unreachable");
}
@Override // com.google.common.collect.Cut
Cut<Comparable<?>> withUpperBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
throw new IllegalStateException();
}
@Override // com.google.common.collect.Cut
void describeAsLowerBound(StringBuilder sb) {
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
void describeAsUpperBound(StringBuilder sb) {
sb.append("+∞)");
}
@Override // com.google.common.collect.Cut
Comparable<?> leastValueAbove(DiscreteDomain<Comparable<?>> discreteDomain) {
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
Comparable<?> greatestValueBelow(DiscreteDomain<Comparable<?>> discreteDomain) {
return discreteDomain.maxValue();
}
@Override // com.google.common.collect.Cut
public int hashCode() {
return System.identityHashCode(this);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <C extends Comparable> Cut<C> belowValue(C c) {
return new BelowValue(c);
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public static final class BelowValue<C extends Comparable> extends Cut<C> {
private static final long serialVersionUID = 0;
@Override // com.google.common.collect.Cut, java.lang.Comparable
public /* bridge */ /* synthetic */ int compareTo(Object obj) {
return super.compareTo((Cut) obj);
}
BelowValue(C c) {
super((Comparable) Preconditions.checkNotNull(c));
}
@Override // com.google.common.collect.Cut
boolean isLessThan(C c) {
return Range.compareOrThrow(this.endpoint, c) <= 0;
}
@Override // com.google.common.collect.Cut
BoundType typeAsLowerBound() {
return BoundType.CLOSED;
}
@Override // com.google.common.collect.Cut
BoundType typeAsUpperBound() {
return BoundType.OPEN;
}
@Override // com.google.common.collect.Cut
Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain) {
int i = AnonymousClass1.$SwitchMap$com$google$common$collect$BoundType[boundType.ordinal()];
if (i == 1) {
return this;
}
if (i == 2) {
C previous = discreteDomain.previous(this.endpoint);
return previous == null ? Cut.belowAll() : new AboveValue(previous);
}
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain) {
int i = AnonymousClass1.$SwitchMap$com$google$common$collect$BoundType[boundType.ordinal()];
if (i == 1) {
C previous = discreteDomain.previous(this.endpoint);
return previous == null ? Cut.aboveAll() : new AboveValue(previous);
}
if (i == 2) {
return this;
}
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
void describeAsLowerBound(StringBuilder sb) {
sb.append('[').append(this.endpoint);
}
@Override // com.google.common.collect.Cut
void describeAsUpperBound(StringBuilder sb) {
sb.append(this.endpoint).append(')');
}
@Override // com.google.common.collect.Cut
C leastValueAbove(DiscreteDomain<C> discreteDomain) {
return this.endpoint;
}
@Override // com.google.common.collect.Cut
@CheckForNull
C greatestValueBelow(DiscreteDomain<C> discreteDomain) {
return discreteDomain.previous(this.endpoint);
}
@Override // com.google.common.collect.Cut
public int hashCode() {
return this.endpoint.hashCode();
}
public String toString() {
String valueOf = String.valueOf(this.endpoint);
return new StringBuilder(String.valueOf(valueOf).length() + 2).append("\\").append(valueOf).append("/").toString();
}
}
/* renamed from: com.google.common.collect.Cut$1, reason: invalid class name */
/* loaded from: classes3.dex */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] $SwitchMap$com$google$common$collect$BoundType;
static {
int[] iArr = new int[BoundType.values().length];
$SwitchMap$com$google$common$collect$BoundType = iArr;
try {
iArr[BoundType.CLOSED.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$common$collect$BoundType[BoundType.OPEN.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <C extends Comparable> Cut<C> aboveValue(C c) {
return new AboveValue(c);
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes3.dex */
public static final class AboveValue<C extends Comparable> extends Cut<C> {
private static final long serialVersionUID = 0;
@Override // com.google.common.collect.Cut, java.lang.Comparable
public /* bridge */ /* synthetic */ int compareTo(Object obj) {
return super.compareTo((Cut) obj);
}
AboveValue(C c) {
super((Comparable) Preconditions.checkNotNull(c));
}
@Override // com.google.common.collect.Cut
boolean isLessThan(C c) {
return Range.compareOrThrow(this.endpoint, c) < 0;
}
@Override // com.google.common.collect.Cut
BoundType typeAsLowerBound() {
return BoundType.OPEN;
}
@Override // com.google.common.collect.Cut
BoundType typeAsUpperBound() {
return BoundType.CLOSED;
}
@Override // com.google.common.collect.Cut
Cut<C> withLowerBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain) {
int i = AnonymousClass1.$SwitchMap$com$google$common$collect$BoundType[boundType.ordinal()];
if (i == 1) {
C next = discreteDomain.next(this.endpoint);
return next == null ? Cut.belowAll() : belowValue(next);
}
if (i == 2) {
return this;
}
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
Cut<C> withUpperBoundType(BoundType boundType, DiscreteDomain<C> discreteDomain) {
int i = AnonymousClass1.$SwitchMap$com$google$common$collect$BoundType[boundType.ordinal()];
if (i == 1) {
return this;
}
if (i == 2) {
C next = discreteDomain.next(this.endpoint);
return next == null ? Cut.aboveAll() : belowValue(next);
}
throw new AssertionError();
}
@Override // com.google.common.collect.Cut
void describeAsLowerBound(StringBuilder sb) {
sb.append('(').append(this.endpoint);
}
@Override // com.google.common.collect.Cut
void describeAsUpperBound(StringBuilder sb) {
sb.append(this.endpoint).append(']');
}
@Override // com.google.common.collect.Cut
@CheckForNull
C leastValueAbove(DiscreteDomain<C> discreteDomain) {
return discreteDomain.next(this.endpoint);
}
@Override // com.google.common.collect.Cut
C greatestValueBelow(DiscreteDomain<C> discreteDomain) {
return this.endpoint;
}
@Override // com.google.common.collect.Cut
Cut<C> canonical(DiscreteDomain<C> discreteDomain) {
C leastValueAbove = leastValueAbove(discreteDomain);
return leastValueAbove != null ? belowValue(leastValueAbove) : Cut.aboveAll();
}
@Override // com.google.common.collect.Cut
public int hashCode() {
return ~this.endpoint.hashCode();
}
public String toString() {
String valueOf = String.valueOf(this.endpoint);
return new StringBuilder(String.valueOf(valueOf).length() + 2).append("/").append(valueOf).append("\\").toString();
}
}
}