package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.EnumMap; import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; /* loaded from: classes2.dex */ public abstract class MultimapBuilder { private static final int DEFAULT_EXPECTED_KEYS = 8; public abstract Multimap build(); private MultimapBuilder() { } public static MultimapBuilderWithKeys hashKeys() { return hashKeys(8); } public static MultimapBuilderWithKeys hashKeys(int i) { CollectPreconditions.checkNonnegative(i, "expectedKeys"); return new MultimapBuilderWithKeys(i) { // from class: com.google.common.collect.MultimapBuilder.1 final int val$expectedKeys; { this.val$expectedKeys = i; } @Override // com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys Map> createMap() { return Platform.newHashMapWithExpectedSize(this.val$expectedKeys); } }; } public static MultimapBuilderWithKeys linkedHashKeys() { return linkedHashKeys(8); } public static MultimapBuilderWithKeys linkedHashKeys(int i) { CollectPreconditions.checkNonnegative(i, "expectedKeys"); return new MultimapBuilderWithKeys(i) { // from class: com.google.common.collect.MultimapBuilder.2 final int val$expectedKeys; { this.val$expectedKeys = i; } @Override // com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys Map> createMap() { return Platform.newLinkedHashMapWithExpectedSize(this.val$expectedKeys); } }; } public static MultimapBuilderWithKeys treeKeys() { return treeKeys(Ordering.natural()); } public static MultimapBuilderWithKeys treeKeys(Comparator comparator) { Preconditions.checkNotNull(comparator); return new MultimapBuilderWithKeys(comparator) { // from class: com.google.common.collect.MultimapBuilder.3 final Comparator val$comparator; { this.val$comparator = comparator; } @Override // com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys Map> createMap() { return new TreeMap(this.val$comparator); } }; } public static > MultimapBuilderWithKeys enumKeys(Class cls) { Preconditions.checkNotNull(cls); return new MultimapBuilderWithKeys(cls) { // from class: com.google.common.collect.MultimapBuilder.4 final Class val$keyClass; { this.val$keyClass = cls; } @Override // com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys Map> createMap() { return new EnumMap(this.val$keyClass); } }; } /* loaded from: classes2.dex */ static final class ArrayListSupplier implements Supplier>, Serializable { private final int expectedValuesPerKey; ArrayListSupplier(int i) { this.expectedValuesPerKey = CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); } @Override // com.google.common.base.Supplier public final List get() { return new ArrayList(this.expectedValuesPerKey); } } /* loaded from: classes2.dex */ enum LinkedListSupplier implements Supplier> { INSTANCE; @Override // com.google.common.base.Supplier public final List get() { return new LinkedList(); } public static Supplier> instance() { return INSTANCE; } } /* loaded from: classes2.dex */ static final class HashSetSupplier implements Supplier>, Serializable { private final int expectedValuesPerKey; HashSetSupplier(int i) { this.expectedValuesPerKey = CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); } @Override // com.google.common.base.Supplier public final Set get() { return Platform.newHashSetWithExpectedSize(this.expectedValuesPerKey); } } /* loaded from: classes2.dex */ static final class LinkedHashSetSupplier implements Supplier>, Serializable { private final int expectedValuesPerKey; LinkedHashSetSupplier(int i) { this.expectedValuesPerKey = CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); } @Override // com.google.common.base.Supplier public final Set get() { return Platform.newLinkedHashSetWithExpectedSize(this.expectedValuesPerKey); } } /* loaded from: classes2.dex */ static final class TreeSetSupplier implements Supplier>, Serializable { private final Comparator comparator; TreeSetSupplier(Comparator comparator) { this.comparator = (Comparator) Preconditions.checkNotNull(comparator); } @Override // com.google.common.base.Supplier public final SortedSet get() { return new TreeSet(this.comparator); } } /* loaded from: classes2.dex */ static final class EnumSetSupplier> implements Supplier>, Serializable { private final Class clazz; EnumSetSupplier(Class cls) { this.clazz = (Class) Preconditions.checkNotNull(cls); } @Override // com.google.common.base.Supplier public final Set get() { return EnumSet.noneOf(this.clazz); } } /* loaded from: classes2.dex */ public static abstract class MultimapBuilderWithKeys { private static final int DEFAULT_EXPECTED_VALUES_PER_KEY = 2; abstract Map> createMap(); MultimapBuilderWithKeys() { } public ListMultimapBuilder arrayListValues() { return arrayListValues(2); } public ListMultimapBuilder arrayListValues(int i) { CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); return new ListMultimapBuilder(this, i) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.1 final MultimapBuilderWithKeys this$0; final int val$expectedValuesPerKey; { this.this$0 = this; this.val$expectedValuesPerKey = i; } @Override // com.google.common.collect.MultimapBuilder.ListMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.ListMultimapBuilder, com.google.common.collect.MultimapBuilder public ListMultimap build() { return Multimaps.newListMultimap(this.this$0.createMap(), new ArrayListSupplier(this.val$expectedValuesPerKey)); } }; } public ListMultimapBuilder linkedListValues() { return new ListMultimapBuilder(this) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.2 final MultimapBuilderWithKeys this$0; { this.this$0 = this; } @Override // com.google.common.collect.MultimapBuilder.ListMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.ListMultimapBuilder, com.google.common.collect.MultimapBuilder public ListMultimap build() { return Multimaps.newListMultimap(this.this$0.createMap(), LinkedListSupplier.instance()); } }; } public SetMultimapBuilder hashSetValues() { return hashSetValues(2); } public SetMultimapBuilder hashSetValues(int i) { CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); return new SetMultimapBuilder(this, i) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.3 final MultimapBuilderWithKeys this$0; final int val$expectedValuesPerKey; { this.this$0 = this; this.val$expectedValuesPerKey = i; } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public SetMultimap build() { return Multimaps.newSetMultimap(this.this$0.createMap(), new HashSetSupplier(this.val$expectedValuesPerKey)); } }; } public SetMultimapBuilder linkedHashSetValues() { return linkedHashSetValues(2); } public SetMultimapBuilder linkedHashSetValues(int i) { CollectPreconditions.checkNonnegative(i, "expectedValuesPerKey"); return new SetMultimapBuilder(this, i) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.4 final MultimapBuilderWithKeys this$0; final int val$expectedValuesPerKey; { this.this$0 = this; this.val$expectedValuesPerKey = i; } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public SetMultimap build() { return Multimaps.newSetMultimap(this.this$0.createMap(), new LinkedHashSetSupplier(this.val$expectedValuesPerKey)); } }; } public SortedSetMultimapBuilder treeSetValues() { return treeSetValues(Ordering.natural()); } public SortedSetMultimapBuilder treeSetValues(Comparator comparator) { Preconditions.checkNotNull(comparator, "comparator"); return new SortedSetMultimapBuilder(this, comparator) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.5 final MultimapBuilderWithKeys this$0; final Comparator val$comparator; { this.this$0 = this; this.val$comparator = comparator; } @Override // com.google.common.collect.MultimapBuilder.SortedSetMultimapBuilder, com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.SortedSetMultimapBuilder, com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ SetMultimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.SortedSetMultimapBuilder, com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public SortedSetMultimap build() { return Multimaps.newSortedSetMultimap(this.this$0.createMap(), new TreeSetSupplier(this.val$comparator)); } }; } public > SetMultimapBuilder enumSetValues(Class cls) { Preconditions.checkNotNull(cls, "valueClass"); return new SetMultimapBuilder(this, cls) { // from class: com.google.common.collect.MultimapBuilder.MultimapBuilderWithKeys.6 final MultimapBuilderWithKeys this$0; final Class val$valueClass; { this.this$0 = this; this.val$valueClass = cls; } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public /* bridge */ /* synthetic */ Multimap build() { return build(); } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public SetMultimap build() { return Multimaps.newSetMultimap(this.this$0.createMap(), new EnumSetSupplier(this.val$valueClass)); } }; } } public Multimap build(Multimap multimap) { Multimap build = build(); build.putAll(multimap); return build; } /* loaded from: classes2.dex */ public static abstract class ListMultimapBuilder extends MultimapBuilder { @Override // com.google.common.collect.MultimapBuilder public abstract ListMultimap build(); ListMultimapBuilder() { super(); } @Override // com.google.common.collect.MultimapBuilder public ListMultimap build(Multimap multimap) { return (ListMultimap) super.build((Multimap) multimap); } } /* loaded from: classes2.dex */ public static abstract class SetMultimapBuilder extends MultimapBuilder { @Override // com.google.common.collect.MultimapBuilder public abstract SetMultimap build(); SetMultimapBuilder() { super(); } @Override // com.google.common.collect.MultimapBuilder public SetMultimap build(Multimap multimap) { return (SetMultimap) super.build((Multimap) multimap); } } /* loaded from: classes2.dex */ public static abstract class SortedSetMultimapBuilder extends SetMultimapBuilder { @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public abstract SortedSetMultimap build(); SortedSetMultimapBuilder() { } @Override // com.google.common.collect.MultimapBuilder.SetMultimapBuilder, com.google.common.collect.MultimapBuilder public SortedSetMultimap build(Multimap multimap) { return (SortedSetMultimap) super.build((Multimap) multimap); } } }