1346 lines
60 KiB
Java
1346 lines
60 KiB
Java
|
package com.google.common.collect;
|
||
|
|
||
|
import com.google.common.base.Function;
|
||
|
import com.google.common.base.Preconditions;
|
||
|
import com.google.common.base.Predicate;
|
||
|
import com.google.common.base.Predicates;
|
||
|
import com.google.common.base.Supplier;
|
||
|
import com.google.common.collect.AbstractMapBasedMultimap;
|
||
|
import com.google.common.collect.AbstractMultimap;
|
||
|
import com.google.common.collect.ImmutableListMultimap;
|
||
|
import com.google.common.collect.Maps;
|
||
|
import com.google.common.collect.Multiset;
|
||
|
import com.google.common.collect.Multisets;
|
||
|
import com.google.common.collect.Sets;
|
||
|
import java.io.IOException;
|
||
|
import java.io.ObjectInputStream;
|
||
|
import java.io.ObjectOutputStream;
|
||
|
import java.io.Serializable;
|
||
|
import java.util.AbstractCollection;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Collections;
|
||
|
import java.util.Comparator;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.NavigableSet;
|
||
|
import java.util.NoSuchElementException;
|
||
|
import java.util.Set;
|
||
|
import java.util.SortedSet;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class Multimaps {
|
||
|
private Multimaps() {
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> newMultimap(Map<K, Collection<V>> map, Supplier<? extends Collection<V>> supplier) {
|
||
|
return new CustomMultimap(map, supplier);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class CustomMultimap<K, V> extends AbstractMapBasedMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
transient Supplier<? extends Collection<V>> factory;
|
||
|
|
||
|
CustomMultimap(Map<K, Collection<V>> map, Supplier<? extends Collection<V>> supplier) {
|
||
|
super(map);
|
||
|
this.factory = (Supplier) Preconditions.checkNotNull(supplier);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return createMaybeNavigableKeySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V>> createAsMap() {
|
||
|
return createMaybeNavigableAsMap();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap
|
||
|
protected Collection<V> createCollection() {
|
||
|
return this.factory.get();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap
|
||
|
<E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
|
||
|
if (collection instanceof NavigableSet) {
|
||
|
return Sets.unmodifiableNavigableSet((NavigableSet) collection);
|
||
|
}
|
||
|
if (collection instanceof SortedSet) {
|
||
|
return Collections.unmodifiableSortedSet((SortedSet) collection);
|
||
|
}
|
||
|
if (collection instanceof Set) {
|
||
|
return Collections.unmodifiableSet((Set) collection);
|
||
|
}
|
||
|
if (collection instanceof List) {
|
||
|
return Collections.unmodifiableList((List) collection);
|
||
|
}
|
||
|
return Collections.unmodifiableCollection(collection);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap
|
||
|
Collection<V> wrapCollection(K k, Collection<V> collection) {
|
||
|
if (collection instanceof List) {
|
||
|
return wrapList(k, (List) collection, null);
|
||
|
}
|
||
|
if (collection instanceof NavigableSet) {
|
||
|
return new AbstractMapBasedMultimap.WrappedNavigableSet(this, k, (NavigableSet) collection, null);
|
||
|
}
|
||
|
if (collection instanceof SortedSet) {
|
||
|
return new AbstractMapBasedMultimap.WrappedSortedSet(this, k, (SortedSet) collection, null);
|
||
|
}
|
||
|
if (collection instanceof Set) {
|
||
|
return new AbstractMapBasedMultimap.WrappedSet(this, k, (Set) collection);
|
||
|
}
|
||
|
return new AbstractMapBasedMultimap.WrappedCollection(this, k, collection, null);
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(this.factory);
|
||
|
objectOutputStream.writeObject(backingMap());
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
this.factory = (Supplier) objectInputStream.readObject();
|
||
|
setMap((Map) objectInputStream.readObject());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> ListMultimap<K, V> newListMultimap(Map<K, Collection<V>> map, Supplier<? extends List<V>> supplier) {
|
||
|
return new CustomListMultimap(map, supplier);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class CustomListMultimap<K, V> extends AbstractListMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
transient Supplier<? extends List<V>> factory;
|
||
|
|
||
|
CustomListMultimap(Map<K, Collection<V>> map, Supplier<? extends List<V>> supplier) {
|
||
|
super(map);
|
||
|
this.factory = (Supplier) Preconditions.checkNotNull(supplier);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return createMaybeNavigableKeySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V>> createAsMap() {
|
||
|
return createMaybeNavigableAsMap();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // com.google.common.collect.AbstractListMultimap, com.google.common.collect.AbstractMapBasedMultimap
|
||
|
public List<V> createCollection() {
|
||
|
return this.factory.get();
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(this.factory);
|
||
|
objectOutputStream.writeObject(backingMap());
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
this.factory = (Supplier) objectInputStream.readObject();
|
||
|
setMap((Map) objectInputStream.readObject());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> newSetMultimap(Map<K, Collection<V>> map, Supplier<? extends Set<V>> supplier) {
|
||
|
return new CustomSetMultimap(map, supplier);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class CustomSetMultimap<K, V> extends AbstractSetMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
transient Supplier<? extends Set<V>> factory;
|
||
|
|
||
|
CustomSetMultimap(Map<K, Collection<V>> map, Supplier<? extends Set<V>> supplier) {
|
||
|
super(map);
|
||
|
this.factory = (Supplier) Preconditions.checkNotNull(supplier);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return createMaybeNavigableKeySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V>> createAsMap() {
|
||
|
return createMaybeNavigableAsMap();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap
|
||
|
public Set<V> createCollection() {
|
||
|
return this.factory.get();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap
|
||
|
<E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
|
||
|
if (collection instanceof NavigableSet) {
|
||
|
return Sets.unmodifiableNavigableSet((NavigableSet) collection);
|
||
|
}
|
||
|
if (collection instanceof SortedSet) {
|
||
|
return Collections.unmodifiableSortedSet((SortedSet) collection);
|
||
|
}
|
||
|
return Collections.unmodifiableSet((Set) collection);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap
|
||
|
Collection<V> wrapCollection(K k, Collection<V> collection) {
|
||
|
if (collection instanceof NavigableSet) {
|
||
|
return new AbstractMapBasedMultimap.WrappedNavigableSet(this, k, (NavigableSet) collection, null);
|
||
|
}
|
||
|
if (collection instanceof SortedSet) {
|
||
|
return new AbstractMapBasedMultimap.WrappedSortedSet(this, k, (SortedSet) collection, null);
|
||
|
}
|
||
|
return new AbstractMapBasedMultimap.WrappedSet(this, k, (Set) collection);
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(this.factory);
|
||
|
objectOutputStream.writeObject(backingMap());
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
this.factory = (Supplier) objectInputStream.readObject();
|
||
|
setMap((Map) objectInputStream.readObject());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> SortedSetMultimap<K, V> newSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> supplier) {
|
||
|
return new CustomSortedSetMultimap(map, supplier);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class CustomSortedSetMultimap<K, V> extends AbstractSortedSetMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
transient Supplier<? extends SortedSet<V>> factory;
|
||
|
transient Comparator<? super V> valueComparator;
|
||
|
|
||
|
CustomSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> supplier) {
|
||
|
super(map);
|
||
|
this.factory = (Supplier) Preconditions.checkNotNull(supplier);
|
||
|
this.valueComparator = supplier.get().comparator();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return createMaybeNavigableKeySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMapBasedMultimap, com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V>> createAsMap() {
|
||
|
return createMaybeNavigableAsMap();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // com.google.common.collect.AbstractSortedSetMultimap, com.google.common.collect.AbstractSetMultimap, com.google.common.collect.AbstractMapBasedMultimap
|
||
|
public SortedSet<V> createCollection() {
|
||
|
return this.factory.get();
|
||
|
}
|
||
|
|
||
|
private void writeObject(ObjectOutputStream objectOutputStream) throws IOException {
|
||
|
objectOutputStream.defaultWriteObject();
|
||
|
objectOutputStream.writeObject(this.factory);
|
||
|
objectOutputStream.writeObject(backingMap());
|
||
|
}
|
||
|
|
||
|
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||
|
objectInputStream.defaultReadObject();
|
||
|
Supplier<? extends SortedSet<V>> supplier = (Supplier) objectInputStream.readObject();
|
||
|
this.factory = supplier;
|
||
|
this.valueComparator = supplier.get().comparator();
|
||
|
setMap((Map) objectInputStream.readObject());
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.SortedSetMultimap
|
||
|
public Comparator<? super V> valueComparator() {
|
||
|
return this.valueComparator;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V, M extends Multimap<K, V>> M invertFrom(Multimap<? extends V, ? extends K> multimap, M m) {
|
||
|
Preconditions.checkNotNull(m);
|
||
|
for (Map.Entry<? extends V, ? extends K> entry : multimap.entries()) {
|
||
|
m.put(entry.getValue(), entry.getKey());
|
||
|
}
|
||
|
return m;
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> synchronizedMultimap(Multimap<K, V> multimap) {
|
||
|
return Synchronized.multimap(multimap, null);
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> unmodifiableMultimap(Multimap<K, V> multimap) {
|
||
|
return ((multimap instanceof UnmodifiableMultimap) || (multimap instanceof ImmutableMultimap)) ? multimap : new UnmodifiableMultimap(multimap);
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static <K, V> Multimap<K, V> unmodifiableMultimap(ImmutableMultimap<K, V> immutableMultimap) {
|
||
|
return (Multimap) Preconditions.checkNotNull(immutableMultimap);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class UnmodifiableMultimap<K, V> extends ForwardingMultimap<K, V> implements Serializable {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
final Multimap<K, V> delegate;
|
||
|
transient Collection<Map.Entry<K, V>> entries;
|
||
|
transient Set<K> keySet;
|
||
|
transient Multiset<K> keys;
|
||
|
transient Map<K, Collection<V>> map;
|
||
|
transient Collection<V> values;
|
||
|
|
||
|
UnmodifiableMultimap(Multimap<K, V> multimap) {
|
||
|
this.delegate = (Multimap) Preconditions.checkNotNull(multimap);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public void clear() {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap, com.google.common.collect.ListMultimap
|
||
|
public Map<K, Collection<V>> asMap() {
|
||
|
Map<K, Collection<V>> map = this.map;
|
||
|
if (map != null) {
|
||
|
return map;
|
||
|
}
|
||
|
Map<K, Collection<V>> unmodifiableMap = Collections.unmodifiableMap(Maps.transformValues(this.delegate.asMap(), new Function<Collection<V>, Collection<V>>(this) { // from class: com.google.common.collect.Multimaps.UnmodifiableMultimap.1
|
||
|
@Override // com.google.common.base.Function
|
||
|
public Collection<V> apply(Collection<V> collection) {
|
||
|
return Multimaps.unmodifiableValueCollection(collection);
|
||
|
}
|
||
|
}));
|
||
|
this.map = unmodifiableMap;
|
||
|
return unmodifiableMap;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<Map.Entry<K, V>> entries() {
|
||
|
Collection<Map.Entry<K, V>> collection = this.entries;
|
||
|
if (collection != null) {
|
||
|
return collection;
|
||
|
}
|
||
|
Collection<Map.Entry<K, V>> unmodifiableEntries = Multimaps.unmodifiableEntries(this.delegate.entries());
|
||
|
this.entries = unmodifiableEntries;
|
||
|
return unmodifiableEntries;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<V> get(K k) {
|
||
|
return Multimaps.unmodifiableValueCollection(this.delegate.get(k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Multiset<K> keys() {
|
||
|
Multiset<K> multiset = this.keys;
|
||
|
if (multiset != null) {
|
||
|
return multiset;
|
||
|
}
|
||
|
Multiset<K> unmodifiableMultiset = Multisets.unmodifiableMultiset(this.delegate.keys());
|
||
|
this.keys = unmodifiableMultiset;
|
||
|
return unmodifiableMultiset;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Set<K> keySet() {
|
||
|
Set<K> set = this.keySet;
|
||
|
if (set != null) {
|
||
|
return set;
|
||
|
}
|
||
|
Set<K> unmodifiableSet = Collections.unmodifiableSet(this.delegate.keySet());
|
||
|
this.keySet = unmodifiableSet;
|
||
|
return unmodifiableSet;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public boolean put(K k, V v) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public boolean remove(Object obj, Object obj2) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<V> removeAll(Object obj) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<V> values() {
|
||
|
Collection<V> collection = this.values;
|
||
|
if (collection != null) {
|
||
|
return collection;
|
||
|
}
|
||
|
Collection<V> unmodifiableCollection = Collections.unmodifiableCollection(this.delegate.values());
|
||
|
this.values = unmodifiableCollection;
|
||
|
return unmodifiableCollection;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject
|
||
|
public Multimap<K, V> delegate() {
|
||
|
return this.delegate;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class UnmodifiableListMultimap<K, V> extends UnmodifiableMultimap<K, V> implements ListMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||
|
return get((UnmodifiableListMultimap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((UnmodifiableListMultimap<K, V>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
UnmodifiableListMultimap(ListMultimap<K, V> listMultimap) {
|
||
|
super(listMultimap);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject
|
||
|
public ListMultimap<K, V> delegate() {
|
||
|
return (ListMultimap) super.delegate();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public List<V> get(K k) {
|
||
|
return Collections.unmodifiableList(delegate().get((ListMultimap<K, V>) k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public List<V> removeAll(Object obj) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public List<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class UnmodifiableSetMultimap<K, V> extends UnmodifiableMultimap<K, V> implements SetMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||
|
return get((UnmodifiableSetMultimap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((UnmodifiableSetMultimap<K, V>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
UnmodifiableSetMultimap(SetMultimap<K, V> setMultimap) {
|
||
|
super(setMultimap);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject
|
||
|
public SetMultimap<K, V> delegate() {
|
||
|
return (SetMultimap) super.delegate();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Set<V> get(K k) {
|
||
|
return Collections.unmodifiableSet(delegate().get((SetMultimap<K, V>) k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Set<Map.Entry<K, V>> entries() {
|
||
|
return Maps.unmodifiableEntrySet(delegate().entries());
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Set<V> removeAll(Object obj) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public Set<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class UnmodifiableSortedSetMultimap<K, V> extends UnmodifiableSetMultimap<K, V> implements SortedSetMultimap<K, V> {
|
||
|
private static final long serialVersionUID = 0;
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||
|
return get((UnmodifiableSortedSetMultimap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Set get(Object obj) {
|
||
|
return get((UnmodifiableSortedSetMultimap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((UnmodifiableSortedSetMultimap<K, V>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Set replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((UnmodifiableSortedSetMultimap<K, V>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
UnmodifiableSortedSetMultimap(SortedSetMultimap<K, V> sortedSetMultimap) {
|
||
|
super(sortedSetMultimap);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.ForwardingObject
|
||
|
public SortedSetMultimap<K, V> delegate() {
|
||
|
return (SortedSetMultimap) super.delegate();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public SortedSet<V> get(K k) {
|
||
|
return Collections.unmodifiableSortedSet(delegate().get((SortedSetMultimap<K, V>) k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public SortedSet<V> removeAll(Object obj) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.UnmodifiableSetMultimap, com.google.common.collect.Multimaps.UnmodifiableMultimap, com.google.common.collect.ForwardingMultimap, com.google.common.collect.Multimap
|
||
|
public SortedSet<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.SortedSetMultimap
|
||
|
public Comparator<? super V> valueComparator() {
|
||
|
return delegate().valueComparator();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> synchronizedSetMultimap(SetMultimap<K, V> setMultimap) {
|
||
|
return Synchronized.setMultimap(setMultimap, null);
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> unmodifiableSetMultimap(SetMultimap<K, V> setMultimap) {
|
||
|
return ((setMultimap instanceof UnmodifiableSetMultimap) || (setMultimap instanceof ImmutableSetMultimap)) ? setMultimap : new UnmodifiableSetMultimap(setMultimap);
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static <K, V> SetMultimap<K, V> unmodifiableSetMultimap(ImmutableSetMultimap<K, V> immutableSetMultimap) {
|
||
|
return (SetMultimap) Preconditions.checkNotNull(immutableSetMultimap);
|
||
|
}
|
||
|
|
||
|
public static <K, V> SortedSetMultimap<K, V> synchronizedSortedSetMultimap(SortedSetMultimap<K, V> sortedSetMultimap) {
|
||
|
return Synchronized.sortedSetMultimap(sortedSetMultimap, null);
|
||
|
}
|
||
|
|
||
|
public static <K, V> SortedSetMultimap<K, V> unmodifiableSortedSetMultimap(SortedSetMultimap<K, V> sortedSetMultimap) {
|
||
|
return sortedSetMultimap instanceof UnmodifiableSortedSetMultimap ? sortedSetMultimap : new UnmodifiableSortedSetMultimap(sortedSetMultimap);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ListMultimap<K, V> synchronizedListMultimap(ListMultimap<K, V> listMultimap) {
|
||
|
return Synchronized.listMultimap(listMultimap, null);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(ListMultimap<K, V> listMultimap) {
|
||
|
return ((listMultimap instanceof UnmodifiableListMultimap) || (listMultimap instanceof ImmutableListMultimap)) ? listMultimap : new UnmodifiableListMultimap(listMultimap);
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public static <K, V> ListMultimap<K, V> unmodifiableListMultimap(ImmutableListMultimap<K, V> immutableListMultimap) {
|
||
|
return (ListMultimap) Preconditions.checkNotNull(immutableListMultimap);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static <V> Collection<V> unmodifiableValueCollection(Collection<V> collection) {
|
||
|
if (collection instanceof SortedSet) {
|
||
|
return Collections.unmodifiableSortedSet((SortedSet) collection);
|
||
|
}
|
||
|
if (collection instanceof Set) {
|
||
|
return Collections.unmodifiableSet((Set) collection);
|
||
|
}
|
||
|
if (collection instanceof List) {
|
||
|
return Collections.unmodifiableList((List) collection);
|
||
|
}
|
||
|
return Collections.unmodifiableCollection(collection);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public static <K, V> Collection<Map.Entry<K, V>> unmodifiableEntries(Collection<Map.Entry<K, V>> collection) {
|
||
|
if (collection instanceof Set) {
|
||
|
return Maps.unmodifiableEntrySet((Set) collection);
|
||
|
}
|
||
|
return new Maps.UnmodifiableEntries(Collections.unmodifiableCollection(collection));
|
||
|
}
|
||
|
|
||
|
public static <K, V> Map<K, List<V>> asMap(ListMultimap<K, V> listMultimap) {
|
||
|
return listMultimap.asMap();
|
||
|
}
|
||
|
|
||
|
public static <K, V> Map<K, Set<V>> asMap(SetMultimap<K, V> setMultimap) {
|
||
|
return setMultimap.asMap();
|
||
|
}
|
||
|
|
||
|
public static <K, V> Map<K, SortedSet<V>> asMap(SortedSetMultimap<K, V> sortedSetMultimap) {
|
||
|
return sortedSetMultimap.asMap();
|
||
|
}
|
||
|
|
||
|
public static <K, V> Map<K, Collection<V>> asMap(Multimap<K, V> multimap) {
|
||
|
return multimap.asMap();
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> forMap(Map<K, V> map) {
|
||
|
return new MapMultimap(map);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class MapMultimap<K, V> extends AbstractMultimap<K, V> implements SetMultimap<K, V>, Serializable {
|
||
|
private static final long serialVersionUID = 7845222491160860175L;
|
||
|
final Map<K, V> map;
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||
|
return get((MapMultimap<K, V>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((MapMultimap<K, V>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
MapMultimap(Map<K, V> map) {
|
||
|
this.map = (Map) Preconditions.checkNotNull(map);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public int size() {
|
||
|
return this.map.size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public boolean containsKey(Object obj) {
|
||
|
return this.map.containsKey(obj);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean containsValue(Object obj) {
|
||
|
return this.map.containsValue(obj);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean containsEntry(Object obj, Object obj2) {
|
||
|
return this.map.entrySet().contains(Maps.immutableEntry(obj, obj2));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.google.common.collect.Multimaps$MapMultimap$1, reason: invalid class name */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class AnonymousClass1 extends Sets.ImprovedAbstractSet<V> {
|
||
|
final MapMultimap this$0;
|
||
|
final Object val$key;
|
||
|
|
||
|
AnonymousClass1(MapMultimap mapMultimap, Object obj) {
|
||
|
this.this$0 = mapMultimap;
|
||
|
this.val$key = obj;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
||
|
public Iterator<V> iterator() {
|
||
|
return new Iterator<V>(this) { // from class: com.google.common.collect.Multimaps.MapMultimap.1.1
|
||
|
int i;
|
||
|
final AnonymousClass1 this$1;
|
||
|
|
||
|
{
|
||
|
this.this$1 = this;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public boolean hasNext() {
|
||
|
return this.i == 0 && this.this$1.this$0.map.containsKey(this.this$1.val$key);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public V next() {
|
||
|
if (!hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
this.i++;
|
||
|
return this.this$1.this$0.map.get(this.this$1.val$key);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public void remove() {
|
||
|
CollectPreconditions.checkRemove(this.i == 1);
|
||
|
this.i = -1;
|
||
|
this.this$1.this$0.map.remove(this.this$1.val$key);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||
|
public int size() {
|
||
|
return this.this$0.map.containsKey(this.val$key) ? 1 : 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public Set<V> get(K k) {
|
||
|
return new AnonymousClass1(this, k);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean put(K k, V v) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(Multimap<? extends K, ? extends V> multimap) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public Set<V> replaceValues(K k, Iterable<? extends V> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean remove(Object obj, Object obj2) {
|
||
|
return this.map.entrySet().remove(Maps.immutableEntry(obj, obj2));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public Set<V> removeAll(Object obj) {
|
||
|
HashSet hashSet = new HashSet(2);
|
||
|
if (!this.map.containsKey(obj)) {
|
||
|
return hashSet;
|
||
|
}
|
||
|
hashSet.add(this.map.remove(obj));
|
||
|
return hashSet;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public void clear() {
|
||
|
this.map.clear();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return this.map.keySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Collection<V> createValues() {
|
||
|
return this.map.values();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public Set<Map.Entry<K, V>> entries() {
|
||
|
return this.map.entrySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Collection<Map.Entry<K, V>> createEntries() {
|
||
|
throw new AssertionError("unreachable");
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Multiset<K> createKeys() {
|
||
|
return new Keys(this);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Iterator<Map.Entry<K, V>> entryIterator() {
|
||
|
return this.map.entrySet().iterator();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V>> createAsMap() {
|
||
|
return new AsMap(this);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public int hashCode() {
|
||
|
return this.map.hashCode();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V1, V2> Multimap<K, V2> transformValues(Multimap<K, V1> multimap, Function<? super V1, V2> function) {
|
||
|
Preconditions.checkNotNull(function);
|
||
|
return transformEntries(multimap, Maps.asEntryTransformer(function));
|
||
|
}
|
||
|
|
||
|
public static <K, V1, V2> ListMultimap<K, V2> transformValues(ListMultimap<K, V1> listMultimap, Function<? super V1, V2> function) {
|
||
|
Preconditions.checkNotNull(function);
|
||
|
return transformEntries((ListMultimap) listMultimap, Maps.asEntryTransformer(function));
|
||
|
}
|
||
|
|
||
|
public static <K, V1, V2> Multimap<K, V2> transformEntries(Multimap<K, V1> multimap, Maps.EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
|
||
|
return new TransformedEntriesMultimap(multimap, entryTransformer);
|
||
|
}
|
||
|
|
||
|
public static <K, V1, V2> ListMultimap<K, V2> transformEntries(ListMultimap<K, V1> listMultimap, Maps.EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
|
||
|
return new TransformedEntriesListMultimap(listMultimap, entryTransformer);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static class TransformedEntriesMultimap<K, V1, V2> extends AbstractMultimap<K, V2> {
|
||
|
final Multimap<K, V1> fromMultimap;
|
||
|
final Maps.EntryTransformer<? super K, ? super V1, V2> transformer;
|
||
|
|
||
|
TransformedEntriesMultimap(Multimap<K, V1> multimap, Maps.EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
|
||
|
this.fromMultimap = (Multimap) Preconditions.checkNotNull(multimap);
|
||
|
this.transformer = (Maps.EntryTransformer) Preconditions.checkNotNull(entryTransformer);
|
||
|
}
|
||
|
|
||
|
Collection<V2> transform(K k, Collection<V1> collection) {
|
||
|
Function asValueToValueFunction = Maps.asValueToValueFunction(this.transformer, k);
|
||
|
if (collection instanceof List) {
|
||
|
return Lists.transform((List) collection, asValueToValueFunction);
|
||
|
}
|
||
|
return Collections2.transform(collection, asValueToValueFunction);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Map<K, Collection<V2>> createAsMap() {
|
||
|
return Maps.transformEntries(this.fromMultimap.asMap(), new Maps.EntryTransformer<K, Collection<V1>, Collection<V2>>(this) { // from class: com.google.common.collect.Multimaps.TransformedEntriesMultimap.1
|
||
|
final TransformedEntriesMultimap this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Maps.EntryTransformer
|
||
|
public /* bridge */ /* synthetic */ Object transformEntry(Object obj, Object obj2) {
|
||
|
return transformEntry((AnonymousClass1) obj, (Collection) obj2);
|
||
|
}
|
||
|
|
||
|
public Collection<V2> transformEntry(K k, Collection<V1> collection) {
|
||
|
return this.this$0.transform(k, collection);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public void clear() {
|
||
|
this.fromMultimap.clear();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public boolean containsKey(Object obj) {
|
||
|
return this.fromMultimap.containsKey(obj);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Collection<Map.Entry<K, V2>> createEntries() {
|
||
|
return new AbstractMultimap.Entries(this);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Iterator<Map.Entry<K, V2>> entryIterator() {
|
||
|
return Iterators.transform(this.fromMultimap.entries().iterator(), Maps.asEntryToEntryFunction(this.transformer));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public Collection<V2> get(K k) {
|
||
|
return transform(k, this.fromMultimap.get(k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean isEmpty() {
|
||
|
return this.fromMultimap.isEmpty();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Set<K> createKeySet() {
|
||
|
return this.fromMultimap.keySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Multiset<K> createKeys() {
|
||
|
return this.fromMultimap.keys();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean put(K k, V2 v2) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(K k, Iterable<? extends V2> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean putAll(Multimap<? extends K, ? extends V2> multimap) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public boolean remove(Object obj, Object obj2) {
|
||
|
return get(obj).remove(obj2);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public Collection<V2> removeAll(Object obj) {
|
||
|
return transform(obj, this.fromMultimap.removeAll(obj));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public Collection<V2> replaceValues(K k, Iterable<? extends V2> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimap
|
||
|
public int size() {
|
||
|
return this.fromMultimap.size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultimap
|
||
|
Collection<V2> createValues() {
|
||
|
return Collections2.transform(this.fromMultimap.entries(), Maps.asEntryToValueFunction(this.transformer));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static final class TransformedEntriesListMultimap<K, V1, V2> extends TransformedEntriesMultimap<K, V1, V2> implements ListMultimap<K, V2> {
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap
|
||
|
public final /* bridge */ /* synthetic */ Collection get(Object obj) {
|
||
|
return get((TransformedEntriesListMultimap<K, V1, V2>) obj);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public final /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) {
|
||
|
return replaceValues((TransformedEntriesListMultimap<K, V1, V2>) obj, iterable);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap
|
||
|
final /* bridge */ /* synthetic */ Collection transform(Object obj, Collection collection) {
|
||
|
return transform((TransformedEntriesListMultimap<K, V1, V2>) obj, collection);
|
||
|
}
|
||
|
|
||
|
TransformedEntriesListMultimap(ListMultimap<K, V1> listMultimap, Maps.EntryTransformer<? super K, ? super V1, V2> entryTransformer) {
|
||
|
super(listMultimap, entryTransformer);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap
|
||
|
final List<V2> transform(K k, Collection<V1> collection) {
|
||
|
return Lists.transform((List) collection, Maps.asValueToValueFunction(this.transformer, k));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap
|
||
|
public final List<V2> get(K k) {
|
||
|
return transform((TransformedEntriesListMultimap<K, V1, V2>) k, (Collection) this.fromMultimap.get(k));
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.Multimap
|
||
|
public final List<V2> removeAll(Object obj) {
|
||
|
return transform((TransformedEntriesListMultimap<K, V1, V2>) obj, (Collection) this.fromMultimap.removeAll(obj));
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap
|
||
|
public final List<V2> replaceValues(K k, Iterable<? extends V2> iterable) {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableListMultimap<K, V> index(Iterable<V> iterable, Function<? super V, K> function) {
|
||
|
return index(iterable.iterator(), function);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ImmutableListMultimap<K, V> index(Iterator<V> it, Function<? super V, K> function) {
|
||
|
Preconditions.checkNotNull(function);
|
||
|
ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder();
|
||
|
while (it.hasNext()) {
|
||
|
V next = it.next();
|
||
|
Preconditions.checkNotNull(next, it);
|
||
|
builder.put((ImmutableListMultimap.Builder) function.apply(next), (K) next);
|
||
|
}
|
||
|
return builder.build();
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
static class Keys<K, V> extends AbstractMultiset<K> {
|
||
|
final Multimap<K, V> multimap;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public Keys(Multimap<K, V> multimap) {
|
||
|
this.multimap = multimap;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.AbstractMultiset
|
||
|
public Iterator<Multiset.Entry<K>> entryIterator() {
|
||
|
return new TransformedIterator<Map.Entry<K, Collection<V>>, Multiset.Entry<K>>(this, this.multimap.asMap().entrySet().iterator()) { // from class: com.google.common.collect.Multimaps.Keys.1
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
@Override // com.google.common.collect.TransformedIterator
|
||
|
public Multiset.Entry<K> transform(Map.Entry<K, Collection<V>> entry) {
|
||
|
return new Multisets.AbstractEntry<K>(this, entry) { // from class: com.google.common.collect.Multimaps.Keys.1.1
|
||
|
final Map.Entry val$backingEntry;
|
||
|
|
||
|
{
|
||
|
this.val$backingEntry = entry;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multiset.Entry
|
||
|
public K getElement() {
|
||
|
return (K) this.val$backingEntry.getKey();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multiset.Entry
|
||
|
public int getCount() {
|
||
|
return ((Collection) this.val$backingEntry.getValue()).size();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset
|
||
|
int distinctElements() {
|
||
|
return this.multimap.asMap().size();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset
|
||
|
public int size() {
|
||
|
return this.multimap.size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset, java.util.AbstractCollection, java.util.Collection, com.google.common.collect.Multiset
|
||
|
public boolean contains(Object obj) {
|
||
|
return this.multimap.containsKey(obj);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, com.google.common.collect.Multiset
|
||
|
public Iterator<K> iterator() {
|
||
|
return Maps.keyIterator(this.multimap.entries().iterator());
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Multiset
|
||
|
public int count(Object obj) {
|
||
|
Collection collection = (Collection) Maps.safeGet(this.multimap.asMap(), obj);
|
||
|
if (collection == null) {
|
||
|
return 0;
|
||
|
}
|
||
|
return collection.size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset, com.google.common.collect.Multiset
|
||
|
public int remove(Object obj, int i) {
|
||
|
CollectPreconditions.checkNonnegative(i, "occurrences");
|
||
|
if (i == 0) {
|
||
|
return count(obj);
|
||
|
}
|
||
|
Collection collection = (Collection) Maps.safeGet(this.multimap.asMap(), obj);
|
||
|
if (collection == null) {
|
||
|
return 0;
|
||
|
}
|
||
|
int size = collection.size();
|
||
|
if (i >= size) {
|
||
|
collection.clear();
|
||
|
} else {
|
||
|
Iterator it = collection.iterator();
|
||
|
for (int i2 = 0; i2 < i; i2++) {
|
||
|
it.next();
|
||
|
it.remove();
|
||
|
}
|
||
|
}
|
||
|
return size;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset, java.util.AbstractCollection, java.util.Collection
|
||
|
public void clear() {
|
||
|
this.multimap.clear();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset, com.google.common.collect.Multiset
|
||
|
public Set<K> elementSet() {
|
||
|
return this.multimap.keySet();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.AbstractMultiset
|
||
|
Iterator<K> elementIterator() {
|
||
|
throw new AssertionError("should never be called");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static abstract class Entries<K, V> extends AbstractCollection<Map.Entry<K, V>> {
|
||
|
abstract Multimap<K, V> multimap();
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection
|
||
|
public int size() {
|
||
|
return multimap().size();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection
|
||
|
public boolean contains(Object obj) {
|
||
|
if (!(obj instanceof Map.Entry)) {
|
||
|
return false;
|
||
|
}
|
||
|
Map.Entry entry = (Map.Entry) obj;
|
||
|
return multimap().containsEntry(entry.getKey(), entry.getValue());
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection
|
||
|
public boolean remove(Object obj) {
|
||
|
if (!(obj instanceof Map.Entry)) {
|
||
|
return false;
|
||
|
}
|
||
|
Map.Entry entry = (Map.Entry) obj;
|
||
|
return multimap().remove(entry.getKey(), entry.getValue());
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection
|
||
|
public void clear() {
|
||
|
multimap().clear();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static final class AsMap<K, V> extends Maps.ViewCachingAbstractMap<K, Collection<V>> {
|
||
|
private final Multimap<K, V> multimap;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public AsMap(Multimap<K, V> multimap) {
|
||
|
this.multimap = (Multimap) Preconditions.checkNotNull(multimap);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final int size() {
|
||
|
return this.multimap.keySet().size();
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap
|
||
|
protected final Set<Map.Entry<K, Collection<V>>> createEntrySet() {
|
||
|
return new EntrySet(this);
|
||
|
}
|
||
|
|
||
|
final void removeValuesForKey(Object obj) {
|
||
|
this.multimap.keySet().remove(obj);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class EntrySet extends Maps.EntrySet<K, Collection<V>> {
|
||
|
final AsMap this$0;
|
||
|
|
||
|
EntrySet(AsMap asMap) {
|
||
|
this.this$0 = asMap;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
||
|
public Iterator<Map.Entry<K, Collection<V>>> iterator() {
|
||
|
return Maps.asMapEntryIterator(this.this$0.multimap.keySet(), new Function<K, Collection<V>>(this) { // from class: com.google.common.collect.Multimaps.AsMap.EntrySet.1
|
||
|
final EntrySet this$1;
|
||
|
|
||
|
{
|
||
|
this.this$1 = this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.base.Function
|
||
|
public /* bridge */ /* synthetic */ Object apply(Object obj) {
|
||
|
return apply((AnonymousClass1) obj);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.base.Function
|
||
|
public Collection<V> apply(K k) {
|
||
|
return this.this$1.this$0.multimap.get(k);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Maps.EntrySet, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
||
|
public boolean remove(Object obj) {
|
||
|
if (!contains(obj)) {
|
||
|
return false;
|
||
|
}
|
||
|
this.this$0.removeValuesForKey(((Map.Entry) obj).getKey());
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Maps.EntrySet
|
||
|
Map<K, Collection<V>> map() {
|
||
|
return this.this$0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final Collection<V> get(Object obj) {
|
||
|
if (containsKey(obj)) {
|
||
|
return this.multimap.get(obj);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final Collection<V> remove(Object obj) {
|
||
|
if (containsKey(obj)) {
|
||
|
return this.multimap.removeAll(obj);
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.common.collect.Maps.ViewCachingAbstractMap, java.util.AbstractMap, java.util.Map
|
||
|
public final Set<K> keySet() {
|
||
|
return this.multimap.keySet();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final boolean isEmpty() {
|
||
|
return this.multimap.isEmpty();
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final boolean containsKey(Object obj) {
|
||
|
return this.multimap.containsKey(obj);
|
||
|
}
|
||
|
|
||
|
@Override // java.util.AbstractMap, java.util.Map
|
||
|
public final void clear() {
|
||
|
this.multimap.clear();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> filterKeys(Multimap<K, V> multimap, Predicate<? super K> predicate) {
|
||
|
if (multimap instanceof SetMultimap) {
|
||
|
return filterKeys((SetMultimap) multimap, (Predicate) predicate);
|
||
|
}
|
||
|
if (multimap instanceof ListMultimap) {
|
||
|
return filterKeys((ListMultimap) multimap, (Predicate) predicate);
|
||
|
}
|
||
|
if (multimap instanceof FilteredKeyMultimap) {
|
||
|
FilteredKeyMultimap filteredKeyMultimap = (FilteredKeyMultimap) multimap;
|
||
|
return new FilteredKeyMultimap(filteredKeyMultimap.unfiltered, Predicates.and(filteredKeyMultimap.keyPredicate, predicate));
|
||
|
}
|
||
|
if (multimap instanceof FilteredMultimap) {
|
||
|
return filterFiltered((FilteredMultimap) multimap, Maps.keyPredicateOnEntries(predicate));
|
||
|
}
|
||
|
return new FilteredKeyMultimap(multimap, predicate);
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> filterKeys(SetMultimap<K, V> setMultimap, Predicate<? super K> predicate) {
|
||
|
if (setMultimap instanceof FilteredKeySetMultimap) {
|
||
|
FilteredKeySetMultimap filteredKeySetMultimap = (FilteredKeySetMultimap) setMultimap;
|
||
|
return new FilteredKeySetMultimap(filteredKeySetMultimap.unfiltered(), Predicates.and(filteredKeySetMultimap.keyPredicate, predicate));
|
||
|
}
|
||
|
if (setMultimap instanceof FilteredSetMultimap) {
|
||
|
return filterFiltered((FilteredSetMultimap) setMultimap, Maps.keyPredicateOnEntries(predicate));
|
||
|
}
|
||
|
return new FilteredKeySetMultimap(setMultimap, predicate);
|
||
|
}
|
||
|
|
||
|
public static <K, V> ListMultimap<K, V> filterKeys(ListMultimap<K, V> listMultimap, Predicate<? super K> predicate) {
|
||
|
if (listMultimap instanceof FilteredKeyListMultimap) {
|
||
|
FilteredKeyListMultimap filteredKeyListMultimap = (FilteredKeyListMultimap) listMultimap;
|
||
|
return new FilteredKeyListMultimap(filteredKeyListMultimap.unfiltered(), Predicates.and(filteredKeyListMultimap.keyPredicate, predicate));
|
||
|
}
|
||
|
return new FilteredKeyListMultimap(listMultimap, predicate);
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> filterValues(Multimap<K, V> multimap, Predicate<? super V> predicate) {
|
||
|
return filterEntries(multimap, Maps.valuePredicateOnEntries(predicate));
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> filterValues(SetMultimap<K, V> setMultimap, Predicate<? super V> predicate) {
|
||
|
return filterEntries((SetMultimap) setMultimap, Maps.valuePredicateOnEntries(predicate));
|
||
|
}
|
||
|
|
||
|
public static <K, V> Multimap<K, V> filterEntries(Multimap<K, V> multimap, Predicate<? super Map.Entry<K, V>> predicate) {
|
||
|
Preconditions.checkNotNull(predicate);
|
||
|
if (multimap instanceof SetMultimap) {
|
||
|
return filterEntries((SetMultimap) multimap, (Predicate) predicate);
|
||
|
}
|
||
|
if (multimap instanceof FilteredMultimap) {
|
||
|
return filterFiltered((FilteredMultimap) multimap, predicate);
|
||
|
}
|
||
|
return new FilteredEntryMultimap((Multimap) Preconditions.checkNotNull(multimap), predicate);
|
||
|
}
|
||
|
|
||
|
public static <K, V> SetMultimap<K, V> filterEntries(SetMultimap<K, V> setMultimap, Predicate<? super Map.Entry<K, V>> predicate) {
|
||
|
Preconditions.checkNotNull(predicate);
|
||
|
if (setMultimap instanceof FilteredSetMultimap) {
|
||
|
return filterFiltered((FilteredSetMultimap) setMultimap, (Predicate) predicate);
|
||
|
}
|
||
|
return new FilteredEntrySetMultimap((SetMultimap) Preconditions.checkNotNull(setMultimap), predicate);
|
||
|
}
|
||
|
|
||
|
private static <K, V> Multimap<K, V> filterFiltered(FilteredMultimap<K, V> filteredMultimap, Predicate<? super Map.Entry<K, V>> predicate) {
|
||
|
return new FilteredEntryMultimap(filteredMultimap.unfiltered(), Predicates.and(filteredMultimap.entryPredicate(), predicate));
|
||
|
}
|
||
|
|
||
|
private static <K, V> SetMultimap<K, V> filterFiltered(FilteredSetMultimap<K, V> filteredSetMultimap, Predicate<? super Map.Entry<K, V>> predicate) {
|
||
|
return new FilteredEntrySetMultimap(filteredSetMultimap.unfiltered(), Predicates.and(filteredSetMultimap.entryPredicate(), predicate));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static boolean equalsImpl(Multimap<?, ?> multimap, Object obj) {
|
||
|
if (obj == multimap) {
|
||
|
return true;
|
||
|
}
|
||
|
if (obj instanceof Multimap) {
|
||
|
return multimap.asMap().equals(((Multimap) obj).asMap());
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
}
|