package com.google.common.collect; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableCollection; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.RandomAccess; /* loaded from: classes2.dex */ public abstract class ImmutableList extends ImmutableCollection implements List, RandomAccess { private static final UnmodifiableListIterator EMPTY_ITR = new Itr(RegularImmutableList.EMPTY, 0); @Override // com.google.common.collect.ImmutableCollection public final ImmutableList asList() { return this; } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public /* bridge */ /* synthetic */ Iterator iterator() { return iterator(); } public static ImmutableList of() { return (ImmutableList) RegularImmutableList.EMPTY; } public static ImmutableList of(E e) { return construct(e); } public static ImmutableList of(E e, E e2) { return construct(e, e2); } public static ImmutableList of(E e, E e2, E e3) { return construct(e, e2, e3); } public static ImmutableList of(E e, E e2, E e3, E e4) { return construct(e, e2, e3, e4); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5) { return construct(e, e2, e3, e4, e5); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6) { return construct(e, e2, e3, e4, e5, e6); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7) { return construct(e, e2, e3, e4, e5, e6, e7); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7, E e8) { return construct(e, e2, e3, e4, e5, e6, e7, e8); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) { return construct(e, e2, e3, e4, e5, e6, e7, e8, e9); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) { return construct(e, e2, e3, e4, e5, e6, e7, e8, e9, e10); } public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) { return construct(e, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11); } @SafeVarargs public static ImmutableList of(E e, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... eArr) { Preconditions.checkArgument(eArr.length <= 2147483635, "the total number of elements must fit in an int"); Object[] objArr = new Object[eArr.length + 12]; objArr[0] = e; objArr[1] = e2; objArr[2] = e3; objArr[3] = e4; objArr[4] = e5; objArr[5] = e6; objArr[6] = e7; objArr[7] = e8; objArr[8] = e9; objArr[9] = e10; objArr[10] = e11; objArr[11] = e12; System.arraycopy(eArr, 0, objArr, 12, eArr.length); return construct(objArr); } public static ImmutableList copyOf(Iterable iterable) { Preconditions.checkNotNull(iterable); if (iterable instanceof Collection) { return copyOf((Collection) iterable); } return copyOf(iterable.iterator()); } public static ImmutableList copyOf(Collection collection) { if (collection instanceof ImmutableCollection) { ImmutableList asList = ((ImmutableCollection) collection).asList(); return asList.isPartialView() ? asImmutableList(asList.toArray()) : asList; } return construct(collection.toArray()); } public static ImmutableList copyOf(Iterator it) { if (!it.hasNext()) { return of(); } E next = it.next(); if (!it.hasNext()) { return of((Object) next); } return new Builder().add((Builder) next).addAll((Iterator) it).build(); } public static ImmutableList copyOf(E[] eArr) { if (eArr.length == 0) { return of(); } return construct((Object[]) eArr.clone()); } public static > ImmutableList sortedCopyOf(Iterable iterable) { Comparable[] comparableArr = (Comparable[]) Iterables.toArray(iterable, new Comparable[0]); ObjectArrays.checkElementsNotNull(comparableArr); Arrays.sort(comparableArr); return asImmutableList(comparableArr); } public static ImmutableList sortedCopyOf(Comparator comparator, Iterable iterable) { Preconditions.checkNotNull(comparator); Object[] array = Iterables.toArray(iterable); ObjectArrays.checkElementsNotNull(array); Arrays.sort(array, comparator); return asImmutableList(array); } private static ImmutableList construct(Object... objArr) { return asImmutableList(ObjectArrays.checkElementsNotNull(objArr)); } /* JADX INFO: Access modifiers changed from: package-private */ public static ImmutableList asImmutableList(Object[] objArr) { return asImmutableList(objArr, objArr.length); } /* JADX INFO: Access modifiers changed from: package-private */ public static ImmutableList asImmutableList(Object[] objArr, int i) { if (i == 0) { return of(); } return new RegularImmutableList(objArr, i); } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public UnmodifiableIterator iterator() { return listIterator(); } @Override // java.util.List public UnmodifiableListIterator listIterator() { return listIterator(0); } @Override // java.util.List public UnmodifiableListIterator listIterator(int i) { Preconditions.checkPositionIndex(i, size()); return isEmpty() ? (UnmodifiableListIterator) EMPTY_ITR : new Itr(this, i); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class Itr extends AbstractIndexedListIterator { private final ImmutableList list; Itr(ImmutableList immutableList, int i) { super(immutableList.size(), i); this.list = immutableList; } @Override // com.google.common.collect.AbstractIndexedListIterator protected E get(int i) { return this.list.get(i); } } @Override // java.util.List public int indexOf(Object obj) { if (obj == null) { return -1; } return Lists.indexOfImpl(this, obj); } @Override // java.util.List public int lastIndexOf(Object obj) { if (obj == null) { return -1; } return Lists.lastIndexOfImpl(this, obj); } @Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { return indexOf(obj) >= 0; } @Override // java.util.List public ImmutableList subList(int i, int i2) { Preconditions.checkPositionIndexes(i, i2, size()); int i3 = i2 - i; if (i3 == size()) { return this; } if (i3 == 0) { return of(); } return subListUnchecked(i, i2); } ImmutableList subListUnchecked(int i, int i2) { return new SubList(this, i, i2 - i); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public class SubList extends ImmutableList { final transient int length; final transient int offset; final ImmutableList this$0; @Override // com.google.common.collect.ImmutableCollection boolean isPartialView() { return true; } @Override // com.google.common.collect.ImmutableList, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public /* bridge */ /* synthetic */ Iterator iterator() { return super.iterator(); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ ListIterator listIterator() { return super.listIterator(); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ ListIterator listIterator(int i) { return super.listIterator(i); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ List subList(int i, int i2) { return subList(i, i2); } SubList(ImmutableList immutableList, int i, int i2) { this.this$0 = immutableList; this.offset = i; this.length = i2; } @Override // com.google.common.collect.ImmutableCollection Object[] internalArray() { return this.this$0.internalArray(); } @Override // com.google.common.collect.ImmutableCollection int internalArrayStart() { return this.this$0.internalArrayStart() + this.offset; } @Override // com.google.common.collect.ImmutableCollection int internalArrayEnd() { return this.this$0.internalArrayStart() + this.offset + this.length; } @Override // java.util.List public E get(int i) { Preconditions.checkElementIndex(i, this.length); return this.this$0.get(i + this.offset); } @Override // com.google.common.collect.ImmutableList, java.util.List public ImmutableList subList(int i, int i2) { Preconditions.checkPositionIndexes(i, i2, this.length); ImmutableList immutableList = this.this$0; int i3 = this.offset; return immutableList.subList(i + i3, i2 + i3); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public int size() { return this.length; } } @Override // java.util.List @Deprecated public final boolean addAll(int i, Collection collection) { throw new UnsupportedOperationException(); } @Override // java.util.List @Deprecated public final E set(int i, E e) { throw new UnsupportedOperationException(); } @Override // java.util.List @Deprecated public final void add(int i, E e) { throw new UnsupportedOperationException(); } @Override // java.util.List @Deprecated public final E remove(int i) { throw new UnsupportedOperationException(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.ImmutableCollection public int copyIntoArray(Object[] objArr, int i) { int size = size(); for (int i2 = 0; i2 < size; i2++) { objArr[i + i2] = get(i2); } return i + size; } public ImmutableList reverse() { return size() <= 1 ? this : new ReverseImmutableList(this); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class ReverseImmutableList extends ImmutableList { private final transient ImmutableList forwardList; @Override // com.google.common.collect.ImmutableList, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable public /* bridge */ /* synthetic */ Iterator iterator() { return super.iterator(); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ ListIterator listIterator() { return super.listIterator(); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ ListIterator listIterator(int i) { return super.listIterator(i); } @Override // com.google.common.collect.ImmutableList, java.util.List public /* bridge */ /* synthetic */ List subList(int i, int i2) { return subList(i, i2); } ReverseImmutableList(ImmutableList immutableList) { this.forwardList = immutableList; } private int reverseIndex(int i) { return (size() - 1) - i; } private int reversePosition(int i) { return size() - i; } @Override // com.google.common.collect.ImmutableList, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { return this.forwardList.contains(obj); } @Override // com.google.common.collect.ImmutableList, java.util.List public int indexOf(Object obj) { int lastIndexOf = this.forwardList.lastIndexOf(obj); if (lastIndexOf >= 0) { return reverseIndex(lastIndexOf); } return -1; } @Override // com.google.common.collect.ImmutableList, java.util.List public int lastIndexOf(Object obj) { int indexOf = this.forwardList.indexOf(obj); if (indexOf >= 0) { return reverseIndex(indexOf); } return -1; } @Override // com.google.common.collect.ImmutableList, java.util.List public ImmutableList subList(int i, int i2) { Preconditions.checkPositionIndexes(i, i2, size()); return this.forwardList.subList(reversePosition(i2), reversePosition(i)).reverse(); } @Override // java.util.List public E get(int i) { Preconditions.checkElementIndex(i, size()); return this.forwardList.get(reverseIndex(i)); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.List public int size() { return this.forwardList.size(); } @Override // com.google.common.collect.ImmutableCollection boolean isPartialView() { return this.forwardList.isPartialView(); } @Override // com.google.common.collect.ImmutableList public ImmutableList reverse() { return this.forwardList; } } @Override // java.util.Collection, java.util.List public boolean equals(Object obj) { return Lists.equalsImpl(this, obj); } @Override // java.util.Collection, java.util.List public int hashCode() { int size = size(); int i = 1; for (int i2 = 0; i2 < size; i2++) { i = ~(~((i * 31) + get(i2).hashCode())); } return i; } /* loaded from: classes2.dex */ static class SerializedForm implements Serializable { private static final long serialVersionUID = 0; final Object[] elements; /* JADX INFO: Access modifiers changed from: package-private */ public SerializedForm(Object[] objArr) { this.elements = objArr; } Object readResolve() { return ImmutableList.copyOf(this.elements); } } private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException { throw new InvalidObjectException("Use SerializedForm"); } @Override // com.google.common.collect.ImmutableCollection Object writeReplace() { return new SerializedForm(toArray()); } public static Builder builder() { return new Builder<>(); } public static Builder builderWithExpectedSize(int i) { CollectPreconditions.checkNonnegative(i, "expectedSize"); return new Builder<>(i); } /* loaded from: classes2.dex */ public static final class Builder extends ImmutableCollection.ArrayBasedBuilder { /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableCollection.ArrayBasedBuilder, com.google.common.collect.ImmutableCollection.Builder public final /* bridge */ /* synthetic */ ImmutableCollection.ArrayBasedBuilder add(Object obj) { return add((Builder) obj); } /* JADX WARN: Multi-variable type inference failed */ @Override // com.google.common.collect.ImmutableCollection.ArrayBasedBuilder, com.google.common.collect.ImmutableCollection.Builder public final /* bridge */ /* synthetic */ ImmutableCollection.Builder add(Object obj) { return add((Builder) obj); } public Builder() { this(4); } /* JADX INFO: Access modifiers changed from: package-private */ public Builder(int i) { super(i); } @Override // com.google.common.collect.ImmutableCollection.ArrayBasedBuilder, com.google.common.collect.ImmutableCollection.Builder public final Builder add(E e) { super.add((Builder) e); return this; } @Override // com.google.common.collect.ImmutableCollection.ArrayBasedBuilder, com.google.common.collect.ImmutableCollection.Builder public final Builder add(E... eArr) { super.add((Object[]) eArr); return this; } @Override // com.google.common.collect.ImmutableCollection.ArrayBasedBuilder, com.google.common.collect.ImmutableCollection.Builder public final Builder addAll(Iterable iterable) { super.addAll((Iterable) iterable); return this; } @Override // com.google.common.collect.ImmutableCollection.Builder public final Builder addAll(Iterator it) { super.addAll((Iterator) it); return this; } final Builder combine(Builder builder) { addAll(builder.contents, builder.size); return this; } @Override // com.google.common.collect.ImmutableCollection.Builder public final ImmutableList build() { this.forceCopy = true; return ImmutableList.asImmutableList(this.contents, this.size); } } }