discord-jadx/app/src/main/java/j0/l/a/r1.java

79 lines
2.1 KiB
Java

package j0.l.a;
import j0.l.b.c;
import j0.o.l;
import java.util.NoSuchElementException;
import rx.Observable;
import rx.Subscriber;
/* compiled from: OperatorSingle */
public final class r1<T> implements Observable.b<T, T> {
/* compiled from: OperatorSingle */
public static final class a {
public static final r1<?> a = new r1<>();
}
/* compiled from: OperatorSingle */
public static final class b<T> extends Subscriber<T> {
public final Subscriber<? super T> i;
public final boolean j;
public final T k;
public T l;
public boolean m;
public boolean n;
public b(Subscriber<? super T> subscriber, boolean z2, T t) {
this.i = subscriber;
this.j = z2;
this.k = t;
request(2);
}
@Override // j0.g
public void onCompleted() {
if (this.n) {
return;
}
if (this.m) {
this.i.setProducer(new c(this.i, this.l));
} else if (this.j) {
this.i.setProducer(new c(this.i, this.k));
} else {
this.i.onError(new NoSuchElementException("Sequence contains no elements"));
}
}
@Override // j0.g
public void onError(Throwable th) {
if (this.n) {
l.b(th);
} else {
this.i.onError(th);
}
}
@Override // j0.g
public void onNext(T t) {
if (this.n) {
return;
}
if (this.m) {
this.n = true;
this.i.onError(new IllegalArgumentException("Sequence contains too many elements"));
unsubscribe();
return;
}
this.l = t;
this.m = true;
}
}
@Override // j0.k.b
public Object call(Object obj) {
Subscriber subscriber = (Subscriber) obj;
b bVar = new b(subscriber, false, null);
subscriber.add(bVar);
return bVar;
}
}