package com.google.common.collect; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Serialization; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Map; /* loaded from: classes2.dex */ public class ImmutableListMultimap extends ImmutableMultimap implements ListMultimap { private static final long serialVersionUID = 0; private transient ImmutableListMultimap inverse; /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ ImmutableCollection get(Object obj) { return get((ImmutableListMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ Collection get(Object obj) { return get((ImmutableListMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.Multimap public /* bridge */ /* synthetic */ List get(Object obj) { return get((ImmutableListMultimap) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public /* bridge */ /* synthetic */ ImmutableCollection replaceValues(Object obj, Iterable iterable) { return replaceValues((ImmutableListMultimap) obj, iterable); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public /* bridge */ /* synthetic */ Collection replaceValues(Object obj, Iterable iterable) { return replaceValues((ImmutableListMultimap) obj, iterable); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public /* bridge */ /* synthetic */ List replaceValues(Object obj, Iterable iterable) { return replaceValues((ImmutableListMultimap) obj, iterable); } public static ImmutableListMultimap of() { return EmptyImmutableListMultimap.INSTANCE; } public static ImmutableListMultimap of(K k, V v) { Builder builder = builder(); builder.put((Builder) k, (K) v); return builder.build(); } public static ImmutableListMultimap of(K k, V v, K k2, V v2) { Builder builder = builder(); builder.put((Builder) k, (K) v); builder.put((Builder) k2, (K) v2); return builder.build(); } public static ImmutableListMultimap of(K k, V v, K k2, V v2, K k3, V v3) { Builder builder = builder(); builder.put((Builder) k, (K) v); builder.put((Builder) k2, (K) v2); builder.put((Builder) k3, (K) v3); return builder.build(); } public static ImmutableListMultimap of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4) { Builder builder = builder(); builder.put((Builder) k, (K) v); builder.put((Builder) k2, (K) v2); builder.put((Builder) k3, (K) v3); builder.put((Builder) k4, (K) v4); return builder.build(); } public static ImmutableListMultimap of(K k, V v, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) { Builder builder = builder(); builder.put((Builder) k, (K) v); builder.put((Builder) k2, (K) v2); builder.put((Builder) k3, (K) v3); builder.put((Builder) k4, (K) v4); builder.put((Builder) k5, (K) v5); return builder.build(); } public static Builder builder() { return new Builder<>(); } /* loaded from: classes2.dex */ public static final class Builder extends ImmutableMultimap.Builder { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap.Builder public final /* bridge */ /* synthetic */ ImmutableMultimap.Builder put(Object obj, Object obj2) { return put((Builder) obj, obj2); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap.Builder public final /* bridge */ /* synthetic */ ImmutableMultimap.Builder putAll(Object obj, Iterable iterable) { return putAll((Builder) obj, iterable); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableMultimap.Builder public final /* bridge */ /* synthetic */ ImmutableMultimap.Builder putAll(Object obj, Object[] objArr) { return putAll((Builder) obj, objArr); } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder put(K k, V v) { super.put((Builder) k, (K) v); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder put(Map.Entry entry) { super.put((Map.Entry) entry); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder putAll(Iterable> iterable) { super.putAll((Iterable) iterable); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder putAll(K k, Iterable iterable) { super.putAll((Builder) k, (Iterable) iterable); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder putAll(K k, V... vArr) { super.putAll((Builder) k, (Object[]) vArr); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder putAll(Multimap multimap) { super.putAll((Multimap) multimap); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder orderKeysBy(Comparator comparator) { super.orderKeysBy((Comparator) comparator); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder orderValuesBy(Comparator comparator) { super.orderValuesBy((Comparator) comparator); return this; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableMultimap.Builder public final Builder combine(ImmutableMultimap.Builder builder) { super.combine((ImmutableMultimap.Builder) builder); return this; } @Override // com.google.common.collect.ImmutableMultimap.Builder public final ImmutableListMultimap build() { return (ImmutableListMultimap) super.build(); } } public static ImmutableListMultimap copyOf(Multimap multimap) { if (multimap.isEmpty()) { return of(); } if (multimap instanceof ImmutableListMultimap) { ImmutableListMultimap immutableListMultimap = (ImmutableListMultimap) multimap; if (!immutableListMultimap.isPartialView()) { return immutableListMultimap; } } return fromMapEntries(multimap.asMap().entrySet(), null); } public static ImmutableListMultimap copyOf(Iterable> iterable) { return new Builder().putAll((Iterable) iterable).build(); } /* JADX INFO: Access modifiers changed from: package-private */ public static ImmutableListMultimap fromMapEntries(Collection>> collection, Comparator comparator) { ImmutableList sortedCopyOf; if (collection.isEmpty()) { return of(); } ImmutableMap.Builder builder = new ImmutableMap.Builder(collection.size()); int i = 0; for (Map.Entry> entry : collection) { K key = entry.getKey(); Collection value = entry.getValue(); if (comparator == null) { sortedCopyOf = ImmutableList.copyOf((Collection) value); } else { sortedCopyOf = ImmutableList.sortedCopyOf(comparator, value); } if (!sortedCopyOf.isEmpty()) { builder.put(key, sortedCopyOf); i += sortedCopyOf.size(); } } return new ImmutableListMultimap<>(builder.build(), i); } /* JADX INFO: Access modifiers changed from: package-private */ public ImmutableListMultimap(ImmutableMap> immutableMap, int i) { super(immutableMap, i); } @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.Multimap public ImmutableList get(K k) { ImmutableList immutableList = (ImmutableList) this.map.get(k); return immutableList == null ? ImmutableList.of() : immutableList; } @Override // com.google.common.collect.ImmutableMultimap public ImmutableListMultimap inverse() { ImmutableListMultimap immutableListMultimap = this.inverse; if (immutableListMultimap != null) { return immutableListMultimap; } ImmutableListMultimap invert = invert(); this.inverse = invert; return invert; } /* JADX WARN: Multi-variable type inference failed */ private ImmutableListMultimap invert() { Builder builder = builder(); UnmodifiableIterator it = entries().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); builder.put((Builder) entry.getValue(), entry.getKey()); } ImmutableListMultimap build = builder.build(); build.inverse = this; return build; } @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.Multimap @Deprecated public final ImmutableList removeAll(Object obj) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ImmutableMultimap, com.google.common.collect.AbstractMultimap, com.google.common.collect.Multimap @Deprecated public final ImmutableList replaceValues(K k, Iterable iterable) { throw new UnsupportedOperationException(); } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); Serialization.writeMultimap(this, objectOutputStream); } /* JADX WARN: Multi-variable type inference failed */ private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); int readInt = objectInputStream.readInt(); if (readInt < 0) { StringBuilder sb = new StringBuilder(29); sb.append("Invalid key count "); sb.append(readInt); throw new InvalidObjectException(sb.toString()); } ImmutableMap.Builder builder = ImmutableMap.builder(); int i = 0; for (int i2 = 0; i2 < readInt; i2++) { Object readObject = objectInputStream.readObject(); int readInt2 = objectInputStream.readInt(); if (readInt2 <= 0) { StringBuilder sb2 = new StringBuilder(31); sb2.append("Invalid value count "); sb2.append(readInt2); throw new InvalidObjectException(sb2.toString()); } ImmutableList.Builder builder2 = ImmutableList.builder(); for (int i3 = 0; i3 < readInt2; i3++) { builder2.add((ImmutableList.Builder) objectInputStream.readObject()); } builder.put(readObject, builder2.build()); i += readInt2; } try { ImmutableMultimap.FieldSettersHolder.MAP_FIELD_SETTER.set((Serialization.FieldSetter) this, (Object) builder.build()); ImmutableMultimap.FieldSettersHolder.SIZE_FIELD_SETTER.set((Serialization.FieldSetter) this, i); } catch (IllegalArgumentException e) { throw ((InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e)); } } }