477 lines
16 KiB
Java
477 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;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.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 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 */
|
||
|
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(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: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static final class BelowAll extends Cut<Comparable<?>> {
|
||
|
private static final BelowAll INSTANCE = new BelowAll();
|
||
|
private static final long serialVersionUID = 0;
|
||
|
|
||
|
@Override // com.google.common.collect.Cut, java.lang.Comparable
|
||
|
public final int compareTo(Cut<Comparable<?>> cut) {
|
||
|
return cut == this ? 0 : -1;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final boolean isLessThan(Comparable<?> comparable) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private BelowAll() {
|
||
|
super(null);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> endpoint() {
|
||
|
throw new IllegalStateException("range unbounded on this side");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsLowerBound() {
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsUpperBound() {
|
||
|
throw new AssertionError("this statement should be unreachable");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<Comparable<?>> withLowerBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<Comparable<?>> withUpperBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new AssertionError("this statement should be unreachable");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsLowerBound(StringBuilder sb) {
|
||
|
sb.append("(-∞");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsUpperBound(StringBuilder sb) {
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> leastValueAbove(DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
return discreteDomain.minValue();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> greatestValueBelow(DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<Comparable<?>> canonical(DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
try {
|
||
|
return Cut.belowValue(discreteDomain.minValue());
|
||
|
} catch (NoSuchElementException unused) {
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
public final int hashCode() {
|
||
|
return System.identityHashCode(this);
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
return "-∞";
|
||
|
}
|
||
|
|
||
|
private Object readResolve() {
|
||
|
return INSTANCE;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* 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: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static final class AboveAll extends Cut<Comparable<?>> {
|
||
|
private static final AboveAll INSTANCE = new AboveAll();
|
||
|
private static final long serialVersionUID = 0;
|
||
|
|
||
|
@Override // com.google.common.collect.Cut, java.lang.Comparable
|
||
|
public final int compareTo(Cut<Comparable<?>> cut) {
|
||
|
return cut == this ? 0 : 1;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final boolean isLessThan(Comparable<?> comparable) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private AboveAll() {
|
||
|
super(null);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> endpoint() {
|
||
|
throw new IllegalStateException("range unbounded on this side");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsLowerBound() {
|
||
|
throw new AssertionError("this statement should be unreachable");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsUpperBound() {
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<Comparable<?>> withLowerBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new AssertionError("this statement should be unreachable");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<Comparable<?>> withUpperBoundType(BoundType boundType, DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsLowerBound(StringBuilder sb) {
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsUpperBound(StringBuilder sb) {
|
||
|
sb.append("+∞)");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> leastValueAbove(DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Comparable<?> greatestValueBelow(DiscreteDomain<Comparable<?>> discreteDomain) {
|
||
|
return discreteDomain.maxValue();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
public final int hashCode() {
|
||
|
return System.identityHashCode(this);
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
return "+∞";
|
||
|
}
|
||
|
|
||
|
private Object readResolve() {
|
||
|
return INSTANCE;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* 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: package-private */
|
||
|
/* loaded from: classes2.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 final /* 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
|
||
|
final boolean isLessThan(C c) {
|
||
|
return Range.compareOrThrow(this.endpoint, c) <= 0;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsLowerBound() {
|
||
|
return BoundType.CLOSED;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsUpperBound() {
|
||
|
return BoundType.OPEN;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final 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
|
||
|
final 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
|
||
|
final void describeAsLowerBound(StringBuilder sb) {
|
||
|
sb.append('[');
|
||
|
sb.append(this.endpoint);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsUpperBound(StringBuilder sb) {
|
||
|
sb.append(this.endpoint);
|
||
|
sb.append(')');
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final C leastValueAbove(DiscreteDomain<C> discreteDomain) {
|
||
|
return this.endpoint;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final C greatestValueBelow(DiscreteDomain<C> discreteDomain) {
|
||
|
return discreteDomain.previous(this.endpoint);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
public final int hashCode() {
|
||
|
return this.endpoint.hashCode();
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
String valueOf = String.valueOf(this.endpoint);
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 2);
|
||
|
sb.append("\\");
|
||
|
sb.append(valueOf);
|
||
|
sb.append("/");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* renamed from: com.google.common.collect.Cut$1, reason: invalid class name */
|
||
|
/* loaded from: classes2.dex */
|
||
|
static /* synthetic */ class AnonymousClass1 {
|
||
|
static final 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: package-private */
|
||
|
/* loaded from: classes2.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 final /* 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
|
||
|
final boolean isLessThan(C c) {
|
||
|
return Range.compareOrThrow(this.endpoint, c) < 0;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsLowerBound() {
|
||
|
return BoundType.OPEN;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final BoundType typeAsUpperBound() {
|
||
|
return BoundType.CLOSED;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final 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
|
||
|
final 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
|
||
|
final void describeAsLowerBound(StringBuilder sb) {
|
||
|
sb.append('(');
|
||
|
sb.append(this.endpoint);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final void describeAsUpperBound(StringBuilder sb) {
|
||
|
sb.append(this.endpoint);
|
||
|
sb.append(']');
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final C leastValueAbove(DiscreteDomain<C> discreteDomain) {
|
||
|
return discreteDomain.next(this.endpoint);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final C greatestValueBelow(DiscreteDomain<C> discreteDomain) {
|
||
|
return this.endpoint;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
final Cut<C> canonical(DiscreteDomain<C> discreteDomain) {
|
||
|
C leastValueAbove = leastValueAbove(discreteDomain);
|
||
|
return leastValueAbove != null ? belowValue(leastValueAbove) : Cut.aboveAll();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Cut
|
||
|
public final int hashCode() {
|
||
|
return ~this.endpoint.hashCode();
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
String valueOf = String.valueOf(this.endpoint);
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 2);
|
||
|
sb.append("/");
|
||
|
sb.append(valueOf);
|
||
|
sb.append("\\");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public C endpoint() {
|
||
|
return this.endpoint;
|
||
|
}
|
||
|
}
|