175 lines
6.5 KiB
Java
175 lines
6.5 KiB
Java
|
package com.google.common.collect;
|
||
|
|
||
|
import com.google.common.collect.ImmutableMap;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/* loaded from: classes2.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> 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: classes2.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 final /* 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 final 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 final 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 final Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
|
||
|
super.putAll((Map) map);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public final 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 final 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 final Builder<K, V> combine(ImmutableMap.Builder<K, V> builder) {
|
||
|
super.combine((ImmutableMap.Builder) builder);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ImmutableMap.Builder
|
||
|
public final ImmutableBiMap<K, V> build() {
|
||
|
if (this.size == 0) {
|
||
|
return ImmutableBiMap.of();
|
||
|
}
|
||
|
sortEntries();
|
||
|
this.entriesUsed = true;
|
||
|
return new RegularImmutableBiMap(this.alternatingKeysAndValues, this.size);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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
|
||
|
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
|
||
|
@Deprecated
|
||
|
public final V forcePut(K k, V v) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
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);
|
||
|
}
|
||
|
}
|