216 lines
6.6 KiB
Java
216 lines
6.6 KiB
Java
package lombok.core;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
/* loaded from: com.discord-118108.apk:lombok/core/LombokImmutableList.SCL.lombok */
|
|
public final class LombokImmutableList<T> implements Iterable<T> {
|
|
private Object[] content;
|
|
private static final LombokImmutableList<?> EMPTY = new LombokImmutableList<>(new Object[0]);
|
|
|
|
/* renamed from: lombok.core.LombokImmutableList$1 reason: invalid class name */
|
|
/* loaded from: com.discord-118108.apk:lombok/core/LombokImmutableList$1.SCL.lombok */
|
|
class AnonymousClass1 implements Iterator<T> {
|
|
private int idx = 0;
|
|
|
|
AnonymousClass1() {
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.idx < LombokImmutableList.access$0(LombokImmutableList.this).length;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public T next() {
|
|
if (this.idx < LombokImmutableList.access$0(LombokImmutableList.this).length) {
|
|
Object[] access$0 = LombokImmutableList.access$0(LombokImmutableList.this);
|
|
int i = this.idx;
|
|
this.idx = i + 1;
|
|
return (T) access$0[i];
|
|
}
|
|
throw new NoSuchElementException();
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
throw new UnsupportedOperationException("List is immutable");
|
|
}
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of() {
|
|
return (LombokImmutableList<T>) EMPTY;
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t) {
|
|
return new LombokImmutableList<>(new Object[]{t});
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t, T t2) {
|
|
return new LombokImmutableList<>(new Object[]{t, t2});
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t, T t2, T t3) {
|
|
return new LombokImmutableList<>(new Object[]{t, t2, t3});
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t, T t2, T t3, T t4) {
|
|
return new LombokImmutableList<>(new Object[]{t, t2, t3, t4});
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t, T t2, T t3, T t4, T t5) {
|
|
return new LombokImmutableList<>(new Object[]{t, t2, t3, t4, t5});
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> of(T t, T t2, T t3, T t4, T t5, T t6, T... tArr) {
|
|
Object[] objArr = tArr == null ? new Object[1] : tArr;
|
|
Object[] objArr2 = new Object[objArr.length + 6];
|
|
System.arraycopy(objArr, 0, objArr2, 6, objArr.length);
|
|
objArr2[0] = t;
|
|
objArr2[1] = t2;
|
|
objArr2[2] = t3;
|
|
objArr2[3] = t4;
|
|
objArr2[4] = t5;
|
|
objArr2[5] = t6;
|
|
return new LombokImmutableList<>(objArr2);
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> copyOf(Collection<? extends T> collection) {
|
|
return new LombokImmutableList<>(collection.toArray());
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> copyOf(Iterable<? extends T> iterable) {
|
|
ArrayList arrayList = new ArrayList();
|
|
Iterator<? extends T> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add(it.next());
|
|
}
|
|
return copyOf((Collection) arrayList);
|
|
}
|
|
|
|
public static <T> LombokImmutableList<T> copyOf(T[] tArr) {
|
|
Object[] objArr = new Object[tArr.length];
|
|
System.arraycopy(tArr, 0, objArr, 0, tArr.length);
|
|
return new LombokImmutableList<>(objArr);
|
|
}
|
|
|
|
private LombokImmutableList(Object[] objArr) {
|
|
this.content = objArr;
|
|
}
|
|
|
|
public LombokImmutableList<T> replaceElementAt(int i, T t) {
|
|
Object[] objArr = (Object[]) this.content.clone();
|
|
objArr[i] = t;
|
|
return new LombokImmutableList<>(objArr);
|
|
}
|
|
|
|
public LombokImmutableList<T> append(T t) {
|
|
int length = this.content.length;
|
|
Object[] objArr = new Object[length + 1];
|
|
System.arraycopy(this.content, 0, objArr, 0, length);
|
|
objArr[length] = t;
|
|
return new LombokImmutableList<>(objArr);
|
|
}
|
|
|
|
public LombokImmutableList<T> prepend(T t) {
|
|
int length = this.content.length;
|
|
Object[] objArr = new Object[length + 1];
|
|
System.arraycopy(this.content, 0, objArr, 1, length);
|
|
objArr[0] = t;
|
|
return new LombokImmutableList<>(objArr);
|
|
}
|
|
|
|
public int indexOf(T t) {
|
|
int length = this.content.length;
|
|
if (t == null) {
|
|
for (int i = 0; i < length; i++) {
|
|
if (this.content[i] == null) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
if (t.equals(this.content[i2])) {
|
|
return i2;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public LombokImmutableList<T> removeElement(T t) {
|
|
int indexOf = indexOf(t);
|
|
return indexOf == -1 ? this : removeElementAt(indexOf);
|
|
}
|
|
|
|
public LombokImmutableList<T> removeElementAt(int i) {
|
|
int length = this.content.length;
|
|
Object[] objArr = new Object[length - 1];
|
|
if (i > 0) {
|
|
System.arraycopy(this.content, 0, objArr, 0, i);
|
|
}
|
|
if (i < length - 1) {
|
|
System.arraycopy(this.content, i + 1, objArr, i, (length - i) - 1);
|
|
}
|
|
return new LombokImmutableList<>(objArr);
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
return this.content.length == 0;
|
|
}
|
|
|
|
public int size() {
|
|
return this.content.length;
|
|
}
|
|
|
|
public T get(int i) {
|
|
return (T) this.content[i];
|
|
}
|
|
|
|
public boolean contains(T t) {
|
|
if (t == null) {
|
|
for (Object obj : this.content) {
|
|
if (obj == null) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
for (Object obj2 : this.content) {
|
|
if (t.equals(obj2)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // java.lang.Iterable
|
|
public Iterator<T> iterator() {
|
|
return new AnonymousClass1();
|
|
}
|
|
|
|
public String toString() {
|
|
return Arrays.toString(this.content);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (!(obj instanceof LombokImmutableList)) {
|
|
return false;
|
|
}
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
return Arrays.equals(this.content, ((LombokImmutableList) obj).content);
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Arrays.hashCode(this.content);
|
|
}
|
|
|
|
static /* synthetic */ Object[] access$0(LombokImmutableList lombokImmutableList) {
|
|
return lombokImmutableList.content;
|
|
}
|
|
}
|