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 implements Comparable>, Serializable { private static final long serialVersionUID = 0; final C endpoint; /* JADX INFO: Access modifiers changed from: package-private */ public Cut canonical(DiscreteDomain 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 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 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 withLowerBoundType(BoundType boundType, DiscreteDomain discreteDomain); /* JADX INFO: Access modifiers changed from: package-private */ public abstract Cut withUpperBoundType(BoundType boundType, DiscreteDomain discreteDomain); Cut(C c) { this.endpoint = c; } @Override // java.lang.Comparable public int compareTo(Cut 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 Cut belowAll() { return BelowAll.INSTANCE; } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class BelowAll extends Cut> { 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> 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> withLowerBoundType(BoundType boundType, DiscreteDomain> discreteDomain) { throw new IllegalStateException(); } @Override // com.google.common.collect.Cut Cut> withUpperBoundType(BoundType boundType, DiscreteDomain> 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> discreteDomain) { return discreteDomain.minValue(); } @Override // com.google.common.collect.Cut Comparable greatestValueBelow(DiscreteDomain> discreteDomain) { throw new AssertionError(); } @Override // com.google.common.collect.Cut Cut> canonical(DiscreteDomain> 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 Cut aboveAll() { return AboveAll.INSTANCE; } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class AboveAll extends Cut> { 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> 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> withLowerBoundType(BoundType boundType, DiscreteDomain> discreteDomain) { throw new AssertionError("this statement should be unreachable"); } @Override // com.google.common.collect.Cut Cut> withUpperBoundType(BoundType boundType, DiscreteDomain> 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> discreteDomain) { throw new AssertionError(); } @Override // com.google.common.collect.Cut Comparable greatestValueBelow(DiscreteDomain> 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 Cut belowValue(C c) { return new BelowValue(c); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class BelowValue extends Cut { 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 withLowerBoundType(BoundType boundType, DiscreteDomain 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 withUpperBoundType(BoundType boundType, DiscreteDomain 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 discreteDomain) { return this.endpoint; } @Override // com.google.common.collect.Cut @CheckForNull C greatestValueBelow(DiscreteDomain 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 Cut aboveValue(C c) { return new AboveValue(c); } /* JADX INFO: Access modifiers changed from: private */ /* loaded from: classes3.dex */ public static final class AboveValue extends Cut { 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 withLowerBoundType(BoundType boundType, DiscreteDomain 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 withUpperBoundType(BoundType boundType, DiscreteDomain 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 discreteDomain) { return discreteDomain.next(this.endpoint); } @Override // com.google.common.collect.Cut C greatestValueBelow(DiscreteDomain discreteDomain) { return this.endpoint; } @Override // com.google.common.collect.Cut Cut canonical(DiscreteDomain 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(); } } }