jimu-decompiled/sources/com/google/common/collect/AbstractIterator.java
2025-05-13 19:24:51 +02:00

78 lines
1.8 KiB
Java

package com.google.common.collect;
import com.google.common.base.Preconditions;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
public abstract class AbstractIterator<T> extends UnmodifiableIterator<T> {
private State a = State.NOT_READY;
private T b;
/* renamed from: com.google.common.collect.AbstractIterator$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[State.values().length];
static {
try {
a[State.DONE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[State.READY.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
private enum State {
READY,
NOT_READY,
DONE,
FAILED
}
protected AbstractIterator() {
}
private boolean c() {
this.a = State.FAILED;
this.b = a();
if (this.a == State.DONE) {
return false;
}
this.a = State.READY;
return true;
}
protected abstract T a();
protected final T b() {
this.a = State.DONE;
return null;
}
@Override // java.util.Iterator
public final boolean hasNext() {
Preconditions.b(this.a != State.FAILED);
int i = AnonymousClass1.a[this.a.ordinal()];
if (i == 1) {
return false;
}
if (i != 2) {
return c();
}
return true;
}
@Override // java.util.Iterator
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
this.a = State.NOT_READY;
T t = this.b;
this.b = null;
return t;
}
}