package com.google.common.graph; import com.google.common.base.MoreObjects; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.google.common.collect.Ordering; import java.util.Comparator; import java.util.Map; /* loaded from: classes2.dex */ public final class ElementOrder { private final Comparator comparator; private final Type type; /* loaded from: classes2.dex */ public enum Type { UNORDERED, STABLE, INSERTION, SORTED } /* JADX INFO: Access modifiers changed from: package-private */ /* JADX WARN: Multi-variable type inference failed */ public final ElementOrder cast() { return this; } private ElementOrder(Type type, Comparator comparator) { this.type = (Type) Preconditions.checkNotNull(type); this.comparator = comparator; Preconditions.checkState((type == Type.SORTED) == (comparator != null)); } public static ElementOrder unordered() { return new ElementOrder<>(Type.UNORDERED, null); } public static ElementOrder stable() { return new ElementOrder<>(Type.STABLE, null); } public static ElementOrder insertion() { return new ElementOrder<>(Type.INSERTION, null); } public static > ElementOrder natural() { return new ElementOrder<>(Type.SORTED, Ordering.natural()); } public static ElementOrder sorted(Comparator comparator) { return new ElementOrder<>(Type.SORTED, (Comparator) Preconditions.checkNotNull(comparator)); } public final Comparator comparator() { Comparator comparator = this.comparator; if (comparator != null) { return comparator; } throw new UnsupportedOperationException("This ordering does not define a comparator."); } public final boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ElementOrder)) { return false; } ElementOrder elementOrder = (ElementOrder) obj; return this.type == elementOrder.type && Objects.equal(this.comparator, elementOrder.comparator); } public final int hashCode() { return Objects.hashCode(this.type, this.comparator); } public final String toString() { MoreObjects.ToStringHelper add = MoreObjects.toStringHelper(this).add("type", this.type); Comparator comparator = this.comparator; if (comparator != null) { add.add("comparator", comparator); } return add.toString(); } /* renamed from: com.google.common.graph.ElementOrder$1, reason: invalid class name */ /* loaded from: classes2.dex */ static /* synthetic */ class AnonymousClass1 { static final int[] $SwitchMap$com$google$common$graph$ElementOrder$Type; static { int[] iArr = new int[Type.values().length]; $SwitchMap$com$google$common$graph$ElementOrder$Type = iArr; try { iArr[Type.UNORDERED.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { $SwitchMap$com$google$common$graph$ElementOrder$Type[Type.INSERTION.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { $SwitchMap$com$google$common$graph$ElementOrder$Type[Type.STABLE.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { $SwitchMap$com$google$common$graph$ElementOrder$Type[Type.SORTED.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } } } /* JADX INFO: Access modifiers changed from: package-private */ public final Map createMap(int i) { int i2 = AnonymousClass1.$SwitchMap$com$google$common$graph$ElementOrder$Type[this.type.ordinal()]; if (i2 == 1) { return Maps.newHashMapWithExpectedSize(i); } if (i2 == 2 || i2 == 3) { return Maps.newLinkedHashMapWithExpectedSize(i); } if (i2 == 4) { return Maps.newTreeMap(comparator()); } throw new AssertionError(); } public final Type type() { return this.type; } }