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

259 lines
11 KiB
Java

package com.google.common.collect;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
@Override // com.google.common.collect.BiMap
public abstract ImmutableBiMap<V, K> inverse();
public static <K, V> ImmutableBiMap<K, V> of() {
return RegularImmutableBiMap.EMPTY;
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v) {
CollectPreconditions.checkEntryNotNull(k, v);
return new RegularImmutableBiMap(new Object[]{k, v}, 1);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2}, 2);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3}, 3);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4}, 4);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5}, 5);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
CollectPreconditions.checkEntryNotNull(k6, v6);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6}, 6);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
CollectPreconditions.checkEntryNotNull(k6, v6);
CollectPreconditions.checkEntryNotNull(k7, v7);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7}, 7);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
CollectPreconditions.checkEntryNotNull(k6, v6);
CollectPreconditions.checkEntryNotNull(k7, v7);
CollectPreconditions.checkEntryNotNull(k8, v8);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8}, 8);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
CollectPreconditions.checkEntryNotNull(k6, v6);
CollectPreconditions.checkEntryNotNull(k7, v7);
CollectPreconditions.checkEntryNotNull(k8, v8);
CollectPreconditions.checkEntryNotNull(k9, v9);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9}, 9);
}
public static <K, V> ImmutableBiMap<K, V> of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) {
CollectPreconditions.checkEntryNotNull(k, v);
CollectPreconditions.checkEntryNotNull(k2, v2);
CollectPreconditions.checkEntryNotNull(k3, v3);
CollectPreconditions.checkEntryNotNull(k4, v4);
CollectPreconditions.checkEntryNotNull(k5, v5);
CollectPreconditions.checkEntryNotNull(k6, v6);
CollectPreconditions.checkEntryNotNull(k7, v7);
CollectPreconditions.checkEntryNotNull(k8, v8);
CollectPreconditions.checkEntryNotNull(k9, v9);
CollectPreconditions.checkEntryNotNull(k10, v10);
return new RegularImmutableBiMap(new Object[]{k, v, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10}, 10);
}
@SafeVarargs
public static <K, V> ImmutableBiMap<K, V> ofEntries(Map.Entry<? extends K, ? extends V>... entryArr) {
return copyOf((Iterable) Arrays.asList(entryArr));
}
public static <K, V> Builder<K, V> builder() {
return new Builder<>();
}
public static <K, V> Builder<K, V> builderWithExpectedSize(int i) {
CollectPreconditions.checkNonnegative(i, "expectedSize");
return new Builder<>(i);
}
/* loaded from: classes3.dex */
public static final class Builder<K, V> extends ImmutableMap.Builder<K, V> {
/* JADX WARN: Multi-variable type inference failed */
@Override // com.google.common.collect.ImmutableMap.Builder
public /* bridge */ /* synthetic */ ImmutableMap.Builder put(Object obj, Object obj2) {
return put((Builder<K, V>) obj, obj2);
}
public Builder() {
}
Builder(int i) {
super(i);
}
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> put(K k, V v) {
super.put((Builder<K, V>) k, (K) v);
return this;
}
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> put(Map.Entry<? extends K, ? extends V> entry) {
super.put((Map.Entry) entry);
return this;
}
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
super.putAll((Map) map);
return this;
}
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> putAll(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
super.putAll((Iterable) iterable);
return this;
}
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> orderEntriesByValue(Comparator<? super V> comparator) {
super.orderEntriesByValue((Comparator) comparator);
return this;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableMap.Builder
public Builder<K, V> combine(ImmutableMap.Builder<K, V> builder) {
super.combine((ImmutableMap.Builder) builder);
return this;
}
@Override // com.google.common.collect.ImmutableMap.Builder
public ImmutableBiMap<K, V> build() {
return buildOrThrow();
}
@Override // com.google.common.collect.ImmutableMap.Builder
public ImmutableBiMap<K, V> buildOrThrow() {
if (this.size == 0) {
return ImmutableBiMap.of();
}
if (this.valueComparator != null) {
if (this.entriesUsed) {
this.alternatingKeysAndValues = Arrays.copyOf(this.alternatingKeysAndValues, this.size * 2);
}
sortEntries(this.alternatingKeysAndValues, this.size, this.valueComparator);
}
this.entriesUsed = true;
return new RegularImmutableBiMap(this.alternatingKeysAndValues, this.size);
}
@Override // com.google.common.collect.ImmutableMap.Builder
@Deprecated
public ImmutableBiMap<K, V> buildKeepingLast() {
throw new UnsupportedOperationException("Not supported for bimaps");
}
}
public static <K, V> ImmutableBiMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
if (map instanceof ImmutableBiMap) {
ImmutableBiMap<K, V> immutableBiMap = (ImmutableBiMap) map;
if (!immutableBiMap.isPartialView()) {
return immutableBiMap;
}
}
return copyOf((Iterable) map.entrySet());
}
public static <K, V> ImmutableBiMap<K, V> copyOf(Iterable<? extends Map.Entry<? extends K, ? extends V>> iterable) {
return new Builder(iterable instanceof Collection ? ((Collection) iterable).size() : 4).putAll((Iterable) iterable).build();
}
@Override // com.google.common.collect.ImmutableMap, java.util.Map, com.google.common.collect.BiMap
public ImmutableSet<V> values() {
return inverse().keySet();
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableMap
public final ImmutableSet<V> createValues() {
throw new AssertionError("should never be called");
}
@Override // com.google.common.collect.BiMap
@CheckForNull
@Deprecated
public final V forcePut(K k, V v) {
throw new UnsupportedOperationException();
}
/* loaded from: classes3.dex */
private static class SerializedForm<K, V> extends ImmutableMap.SerializedForm<K, V> {
private static final long serialVersionUID = 0;
SerializedForm(ImmutableBiMap<K, V> immutableBiMap) {
super(immutableBiMap);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableMap.SerializedForm
public Builder<K, V> makeBuilder(int i) {
return new Builder<>(i);
}
}
@Override // com.google.common.collect.ImmutableMap
Object writeReplace() {
return new SerializedForm(this);
}
}