@Override public void onComplete() { if (done) { return; } done = true; actual.onComplete(); }
@Override public void onError(Throwable t) { if (done) { RxJavaPlugins.onError(t); return; } done = true; actual.onError(t); }
@Override public void onSubscribe(Subscription s) { if (SubscriptionHelper.validateSubscription(this.s, s)) { return; } this.s = s; actual.onSubscribe(s); }
@Override public void onNext(Try<Optional<T>> t) { if (done) { return; } if (t.hasError()) { s.cancel(); onError(t.error()); } else { Optional<T> o = t.value(); if (o.isPresent()) { actual.onNext(o.get()); } else { s.cancel(); onComplete(); } } }