package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSortedSet; import java.lang.Comparable; import java.util.NoSuchElementException; /* loaded from: classes2.dex */ public abstract class ContiguousSet extends ImmutableSortedSet { final DiscreteDomain domain; /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableSortedSet public abstract ContiguousSet headSetImpl(C c, boolean z); public abstract ContiguousSet intersection(ContiguousSet contiguousSet); public abstract Range range(); public abstract Range range(BoundType boundType, BoundType boundType2); /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableSortedSet public abstract ContiguousSet subSetImpl(C c, boolean z, C c2, boolean z2); /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableSortedSet public abstract ContiguousSet tailSetImpl(C c, boolean z); public static ContiguousSet create(Range range, DiscreteDomain discreteDomain) { Preconditions.checkNotNull(range); Preconditions.checkNotNull(discreteDomain); try { Range intersection = !range.hasLowerBound() ? range.intersection(Range.atLeast(discreteDomain.minValue())) : range; if (!range.hasUpperBound()) { intersection = intersection.intersection(Range.atMost(discreteDomain.maxValue())); } if (intersection.isEmpty() || Range.compareOrThrow(range.lowerBound.leastValueAbove(discreteDomain), range.upperBound.greatestValueBelow(discreteDomain)) > 0) { return new EmptyContiguousSet(discreteDomain); } return new RegularContiguousSet(intersection, discreteDomain); } catch (NoSuchElementException e) { throw new IllegalArgumentException(e); } } public static ContiguousSet closed(int i, int i2) { return create(Range.closed(Integer.valueOf(i), Integer.valueOf(i2)), DiscreteDomain.integers()); } public static ContiguousSet closed(long j, long j2) { return create(Range.closed(Long.valueOf(j), Long.valueOf(j2)), DiscreteDomain.longs()); } public static ContiguousSet closedOpen(int i, int i2) { return create(Range.closedOpen(Integer.valueOf(i), Integer.valueOf(i2)), DiscreteDomain.integers()); } public static ContiguousSet closedOpen(long j, long j2) { return create(Range.closedOpen(Long.valueOf(j), Long.valueOf(j2)), DiscreteDomain.longs()); } /* JADX INFO: Access modifiers changed from: package-private */ public ContiguousSet(DiscreteDomain discreteDomain) { super(Ordering.natural()); this.domain = discreteDomain; } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet, java.util.SortedSet public ContiguousSet headSet(C c) { return headSetImpl((ContiguousSet) Preconditions.checkNotNull(c), false); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet public ContiguousSet headSet(C c, boolean z) { return headSetImpl((ContiguousSet) Preconditions.checkNotNull(c), z); } @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet, java.util.SortedSet public ContiguousSet subSet(C c, C c2) { Preconditions.checkNotNull(c); Preconditions.checkNotNull(c2); Preconditions.checkArgument(comparator().compare(c, c2) <= 0); return subSetImpl((boolean) c, true, (boolean) c2, false); } @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet public ContiguousSet subSet(C c, boolean z, C c2, boolean z2) { Preconditions.checkNotNull(c); Preconditions.checkNotNull(c2); Preconditions.checkArgument(comparator().compare(c, c2) <= 0); return subSetImpl((boolean) c, z, (boolean) c2, z2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet, java.util.SortedSet public ContiguousSet tailSet(C c) { return tailSetImpl((ContiguousSet) Preconditions.checkNotNull(c), true); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableSortedSet, java.util.NavigableSet public ContiguousSet tailSet(C c, boolean z) { return tailSetImpl((ContiguousSet) Preconditions.checkNotNull(c), z); } @Override // com.google.common.collect.ImmutableSortedSet ImmutableSortedSet createDescendingSet() { return new DescendingImmutableSortedSet(this); } @Override // java.util.AbstractCollection public String toString() { return range().toString(); } @Deprecated public static ImmutableSortedSet.Builder builder() { throw new UnsupportedOperationException(); } }