58 lines
1.9 KiB
Java
58 lines
1.9 KiB
Java
package io.reactivex.internal.operators.single;
|
|
|
|
import io.reactivex.Single;
|
|
import io.reactivex.SingleObserver;
|
|
import io.reactivex.SingleSource;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.exceptions.Exceptions;
|
|
import io.reactivex.functions.Function;
|
|
import io.reactivex.internal.functions.ObjectHelper;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class SingleMap<T, R> extends Single<R> {
|
|
final SingleSource<? extends T> a;
|
|
final Function<? super T, ? extends R> b;
|
|
|
|
static final class MapSingleObserver<T, R> implements SingleObserver<T> {
|
|
final SingleObserver<? super R> a;
|
|
final Function<? super T, ? extends R> b;
|
|
|
|
MapSingleObserver(SingleObserver<? super R> singleObserver, Function<? super T, ? extends R> function) {
|
|
this.a = singleObserver;
|
|
this.b = function;
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onError(Throwable th) {
|
|
this.a.onError(th);
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onSubscribe(Disposable disposable) {
|
|
this.a.onSubscribe(disposable);
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onSuccess(T t) {
|
|
try {
|
|
R apply = this.b.apply(t);
|
|
ObjectHelper.a(apply, "The mapper function returned a null value.");
|
|
this.a.onSuccess(apply);
|
|
} catch (Throwable th) {
|
|
Exceptions.b(th);
|
|
onError(th);
|
|
}
|
|
}
|
|
}
|
|
|
|
public SingleMap(SingleSource<? extends T> singleSource, Function<? super T, ? extends R> function) {
|
|
this.a = singleSource;
|
|
this.b = function;
|
|
}
|
|
|
|
@Override // io.reactivex.Single
|
|
protected void b(SingleObserver<? super R> singleObserver) {
|
|
this.a.a(new MapSingleObserver(singleObserver, this.b));
|
|
}
|
|
}
|