87 lines
2.5 KiB
Java
87 lines
2.5 KiB
Java
|
package com.google.common.base;
|
||
|
|
||
|
import java.util.Iterator;
|
||
|
import java.util.NoSuchElementException;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
abstract class AbstractIterator<T> implements Iterator<T> {
|
||
|
private T next;
|
||
|
private State state = State.NOT_READY;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public enum State {
|
||
|
READY,
|
||
|
NOT_READY,
|
||
|
DONE,
|
||
|
FAILED
|
||
|
}
|
||
|
|
||
|
protected abstract T computeNext();
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public final T endOfData() {
|
||
|
this.state = State.DONE;
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.google.common.base.AbstractIterator$1, reason: invalid class name */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public static /* synthetic */ class AnonymousClass1 {
|
||
|
static final int[] $SwitchMap$com$google$common$base$AbstractIterator$State;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[State.values().length];
|
||
|
$SwitchMap$com$google$common$base$AbstractIterator$State = iArr;
|
||
|
try {
|
||
|
iArr[State.DONE.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$google$common$base$AbstractIterator$State[State.READY.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public final boolean hasNext() {
|
||
|
Preconditions.checkState(this.state != State.FAILED);
|
||
|
int i = AnonymousClass1.$SwitchMap$com$google$common$base$AbstractIterator$State[this.state.ordinal()];
|
||
|
if (i == 1) {
|
||
|
return false;
|
||
|
}
|
||
|
if (i != 2) {
|
||
|
return tryToComputeNext();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private boolean tryToComputeNext() {
|
||
|
this.state = State.FAILED;
|
||
|
this.next = computeNext();
|
||
|
if (this.state == State.DONE) {
|
||
|
return false;
|
||
|
}
|
||
|
this.state = State.READY;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public final T next() {
|
||
|
if (!hasNext()) {
|
||
|
throw new NoSuchElementException();
|
||
|
}
|
||
|
this.state = State.NOT_READY;
|
||
|
T t = this.next;
|
||
|
this.next = null;
|
||
|
return t;
|
||
|
}
|
||
|
|
||
|
@Override // java.util.Iterator
|
||
|
public final void remove() {
|
||
|
throw new UnsupportedOperationException();
|
||
|
}
|
||
|
}
|