104 lines
3.2 KiB
Java
104 lines
3.2 KiB
Java
package com.squareup.haha.guava.collect;
|
|
|
|
import com.squareup.haha.guava.base.Joiner;
|
|
import java.io.Serializable;
|
|
import java.util.AbstractCollection;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
|
|
private transient ImmutableList<E> asList;
|
|
|
|
ImmutableCollection() {
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final boolean add(E e) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final boolean addAll(Collection<? extends E> collection) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
public ImmutableList<E> asList() {
|
|
ImmutableList<E> immutableList = this.asList;
|
|
if (immutableList == null) {
|
|
int size = size();
|
|
immutableList = size != 0 ? size != 1 ? new RegularImmutableAsList<>(this, toArray()) : ImmutableList.of((Object) iterator().next()) : ImmutableList.of();
|
|
this.asList = immutableList;
|
|
}
|
|
return immutableList;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final void clear() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean contains(Object obj) {
|
|
return obj != null && super.contains(obj);
|
|
}
|
|
|
|
int copyIntoArray(Object[] objArr, int i) {
|
|
Iterator it = iterator();
|
|
while (it.hasNext()) {
|
|
objArr[i] = it.next();
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
abstract boolean isPartialView();
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable
|
|
public abstract UnmodifiableIterator<E> iterator();
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final boolean remove(Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final boolean removeAll(Collection<?> collection) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
@Deprecated
|
|
public final boolean retainAll(Collection<?> collection) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final Object[] toArray() {
|
|
if (size() == 0) {
|
|
return ObjectArrays.EMPTY_ARRAY;
|
|
}
|
|
Object[] objArr = new Object[size()];
|
|
copyIntoArray(objArr, 0);
|
|
return objArr;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection
|
|
public final <T> T[] toArray(T[] tArr) {
|
|
Joiner.checkNotNull(tArr);
|
|
int size = size();
|
|
if (tArr.length < size) {
|
|
tArr = (T[]) ObjectArrays.newArray(tArr, size);
|
|
} else if (tArr.length > size) {
|
|
tArr[size] = null;
|
|
}
|
|
copyIntoArray(tArr, 0);
|
|
return tArr;
|
|
}
|
|
}
|