Java 类io.reactivex.internal.functions.ObjectHelper 实例源码

项目:DisposableAttach    文件:AttachDisposableCompletable.java   
@Override
protected void subscribeActual(CompletableObserver s) {
    CompletableObserver observer;
    try {
        observer = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachCompletableObserver(observer, this.compositeDisposable));
}
项目:DisposableAttach    文件:AttachDisposableFlowable.java   
@Override
protected void subscribeActual(Subscriber<? super T> s) {

    Subscriber<? super T> subscriber;
    try {
        subscriber = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachSingleObserver<>(subscriber, this.compositeDisposable));
}
项目:DisposableAttach    文件:AttachDisposableObservable.java   
@Override
public void subscribeActual(Observer<? super T> s) {
    Observer<? super T> observer;
    try {
        observer = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachSingleObserver<>(observer, this.compositeDisposable));
}
项目:DisposableAttach    文件:AttachDisposableMaybe.java   
@Override
protected void subscribeActual(MaybeObserver<? super T> s) {
    MaybeObserver<? super T> observer;
    try {
        observer = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachMaybeObserver<>(observer, this.compositeDisposable));
}
项目:DisposableAttach    文件:AttachDisposableSingle.java   
@Override
protected void subscribeActual(SingleObserver<? super T> s) {
    SingleObserver<? super T> observer;
    try {
        observer = ObjectHelper.requireNonNull(s, "Null Observer");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        // can't call onError because no way to know if a Disposable has been set or not
        // can't call onSubscribe because the call might have set a Disposable already
        RxJavaPlugins.onError(e);

        NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
        npe.initCause(e);
        throw npe;
    }

    source.subscribe(new AttachSingleObserver<>(observer, this.compositeDisposable));
}
项目:RxJava2Jdk8Interop    文件:ObservableMapOptional.java   
@Override
public void onNext(T t) {
    if (done) {
        return;
    }

    if (sourceMode == ASYNC) {
        actual.onNext(null);
        return;
    }

    Optional<R> o;

    try {
        o = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Optional");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        fail(ex);
        return;
    }

    if (o.isPresent()) {
        actual.onNext(o.get());
    }
}
项目:RxJava2Jdk8Interop    文件:FlowableMapOptional.java   
@Override
public boolean tryOnNext(T t) {
    if (done) {
        return false;
    }

    if (sourceMode == ASYNC) {
        return actual.tryOnNext(null);
    }

    Optional<R> o;

    try {
        o = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Optional");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        fail(ex);
        return false;
    }

    if (o.isPresent()) {
        return actual.tryOnNext(o.get());
    }
    return false;
}
项目:RxJava2Jdk8Interop    文件:MaybeMapOptional.java   
@Override
public void onSuccess(T value) {
    Optional<R> v;

    try {
        v = ObjectHelper.requireNonNull(mapper.apply(value), "The mapper returned a null Optional");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        actual.onError(ex);
        return;
    }

    if (v.isPresent()) {
        actual.onSuccess(v.get());
    } else {
        actual.onComplete();
    }
}
项目:RxJava2Extensions    文件:MultiHandlerManager.java   
/**
 * The given consumer is invoked with each registered handler instance.
 * <p>
 * Exceptions raised by the invocation of the consumer for a particular
 * handler are printed to the console and the current thread's
 * uncaught exception handler is notified.
 * <p>
 * This method is threadsafe.
 * @param consumer the consumer to invoke
 */
public final void forEach(@NonNull Consumer<H> consumer) {
    ObjectHelper.requireNonNull(consumer, "consumer is null");
    Iterator<HandlerRegistration<H>> it = handlers.iterator();
    while (it.hasNext()) {
        try {
            HandlerRegistration<H> hr = it.next();
            H h = hr.get();
            if (h != null) {
                consumer.accept(h);
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
            Thread t = Thread.currentThread();
            t.getUncaughtExceptionHandler().uncaughtException(t, ex);
        }
    }
}
项目:RxJava2Extensions    文件:MultiHandlerManager.java   
/**
 * The given consumer is invoked with each registered handler instance.
 * <p>
 * Exceptions raised by the invocation of the consumer for a particular
 * handler are printed to the console and the current thread's
 * uncaught exception handler is notified.
 * <p>
 * This method is threadsafe.
 * @param <S> the type of the extra state provided to the consumer
 * @param state the extra state provided to the consumer
 * @param consumer the consumer to invoke
 */
public final <S> void forEach(S state, @NonNull BiConsumer<S, H> consumer) {
    ObjectHelper.requireNonNull(consumer, "consumer is null");
    Iterator<HandlerRegistration<H>> it = handlers.iterator();
    while (it.hasNext()) {
        try {
            HandlerRegistration<H> hr = it.next();
            H h = hr.get();
            if (h != null) {
                consumer.accept(state, h);
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
            Thread t = Thread.currentThread();
            t.getUncaughtExceptionHandler().uncaughtException(t, ex);
        }
    }
}
项目:RxJava2Extensions    文件:FlowableSwitchFlatMap.java   
@Override
public void onNext(T t) {
    Publisher<? extends R> p;
    try {
        p = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        s.cancel();
        onError(ex);
        return;
    }

    SfmInnerSubscriber<T, R> inner = new SfmInnerSubscriber<T, R>(this, bufferSize);
    if (add(inner)) {
        p.subscribe(inner);
    }
}
项目:RxJava2Extensions    文件:FlowableRepeatCallable.java   
void fastpath() {
    Callable<T> c = callable;
    for (;;) {
        if (cancelled) {
            break;
        }

        T v;

        try {
            v = ObjectHelper.requireNonNull(c.call(), "The callable returned a null value");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            actual.onError(ex);
            break;
        }

        actual.onNext(v);
    }
}
项目:RxJava2Extensions    文件:FlowableRepeatCallable.java   
void fastpath() {
    Callable<T> c = callable;
    for (;;) {
        if (cancelled) {
            break;
        }

        T v;

        try {
            v = ObjectHelper.requireNonNull(c.call(), "The callable returned a null value");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            actual.onError(ex);
            break;
        }

        actual.tryOnNext(v);
    }
}
项目:RxJava2Extensions    文件:FlowableExpand.java   
@Override
public void onNext(T t) {
    produced++;
    actual.onNext(t);

    Publisher<? extends T> p;
    try {
        p = ObjectHelper.requireNonNull(expander.apply(t), "The expander returned a null Publisher");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        super.cancel();
        actual.onError(ex);
        drainQueue();
        return;
    }

    queue.offer(p);
}
项目:RxJava2Extensions    文件:NonoConcatIterable.java   
@Override
protected void subscribeActual(Subscriber<? super Void> s) {
    Iterator<? extends Nono> it;

    try {
        it = ObjectHelper.requireNonNull(sources.iterator(), "The sources Iterable returned a null Iterator");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        EmptySubscription.error(ex, s);
        return;
    }

    ConcatSubscriber parent = new ConcatSubscriber(s, it, delayError);
    s.onSubscribe(parent);
    parent.drain();
}
项目:RxJava2Extensions    文件:SoloMap.java   
@Override
public void onNext(T t) {
    if (!done) {
        if (sourceMode == NONE) {
            R v;

            try {
                v = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null value");
            } catch (Throwable ex) {
                fail(ex);
                return;
            }

            actual.onNext(v);
        } else {
            actual.onNext(null);
        }
    }
}
项目:RxJava2Extensions    文件:SoloRetryWhen.java   
@Override
protected void subscribeActual(Subscriber<? super T> s) {
    FlowableProcessor<Throwable> pp = PublishProcessor.<Throwable>create().toSerialized();

    Publisher<?> when;
    try {
        when = ObjectHelper.requireNonNull(handler.apply(pp), "The handler returned a null Publisher");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        EmptySubscription.error(ex, s);
        return;
    }

    RetrySubscriber<T> parent = new RetrySubscriber<T>(s, pp, source);
    s.onSubscribe(parent);

    when.subscribe(parent.other);
    parent.subscribeNext();
}
项目:RxJava2Extensions    文件:PerhapsRetryWhen.java   
@Override
protected void subscribeActual(Subscriber<? super T> s) {
    FlowableProcessor<Throwable> pp = PublishProcessor.<Throwable>create().toSerialized();

    Publisher<?> when;
    try {
        when = ObjectHelper.requireNonNull(handler.apply(pp), "The handler returned a null Publisher");
    } catch (Throwable ex) {
        Exceptions.throwIfFatal(ex);
        EmptySubscription.error(ex, s);
        return;
    }

    RetrySubscriber<T> parent = new RetrySubscriber<T>(s, pp, source);
    s.onSubscribe(parent);

    when.subscribe(parent.other);
    parent.subscribeNext();
}
项目:RxJava2Extensions    文件:SoloZipArray.java   
void onSuccess(int index, T value) {
    values[index] = value;
    if (wip.decrementAndGet() == 0) {
        R v;
        try {
            v = ObjectHelper.requireNonNull(zipper.apply(values), "The zipper returned a null value");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            Arrays.fill(values, null);
            actual.onError(ex);
            return;
        }

        Arrays.fill(values, null);
        complete(v);
    }
}
项目:rxjava2-extras    文件:FlowableStateMachine.java   
@Override
public void onNext(In t) {
    if (done) {
        return;
    }
    if (!createdState()) {
        return;
    }
    if (--count == 0) {
        requestsArrived = true;
        count = requestBatchSize;
    }
    try {
        drainCalled = false;
        state = ObjectHelper.requireNonNull(transition.apply(state, t, this),
                "intermediate state cannot be null");
    } catch (Throwable e) {
        Exceptions.throwIfFatal(e);
        onError(e);
        return;
    }
    if (!drainCalled) {
        drain();
    }
}
项目:rxjava2-extras    文件:FlowableStateMachine.java   
private boolean createdState() {
    if (state == null) {
        try {
            state = ObjectHelper.requireNonNull(initialState.call(),
                    "initial state cannot be null");
            return true;
        } catch (Throwable e) {
            Exceptions.throwIfFatal(e);
            done = true;
            onError_(e);
            return false;
        }
    } else {
        return true;
    }
}
项目:akarnokd-misc    文件:ResourceFlowableToFlowable.java   
@Override
public void onNext(T t) {
    if (done) {
        ResourceFlowable.releaseItem(t, release);
    } else {
        R v;

        try {
            v = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null value");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            upstream.cancel();
            ResourceFlowable.releaseItem(t, release);
            done = true;
            actual.onError(ex);
            return;
        }

        ResourceFlowable.releaseItem(t, release);

        actual.onNext(v);
    }
}
项目:akarnokd-misc    文件:ResourceFlowableMap.java   
@Override
public void onNext(T t) {
    if (done) {
        ResourceFlowable.releaseItem(t, release);
    } else {
        R v;

        try {
            v = ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null value");
        } catch (Throwable ex) {
            Exceptions.throwIfFatal(ex);
            upstream.cancel();
            ResourceFlowable.releaseItem(t, release);
            done = true;
            actual.onError(ex);
            return;
        }

        ResourceFlowable.releaseItem(t, release);

        actual.onNext(v);
    }
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<ActionEvent> actions(@NonNull AbstractButton button) {
    ObjectHelper.requireNonNull(button, "button is null");
    return RxSwingPlugins.onAssembly(new ActionEventObservable(button));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<ActionEvent> actions(@NonNull JComboBox<?> button) {
    ObjectHelper.requireNonNull(button, "button is null");
    return RxSwingPlugins.onAssembly(new ActionEventComboBoxObservable(button));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<MouseEvent> mouse(@NonNull Component component, int flags) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new MouseEventObservable(component, flags));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<MouseWheelEvent> mouseWheel(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new MouseWheelEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<KeyEvent> keyboard(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new KeyEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<FocusEvent> focus(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new FocusEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<HierarchyEvent> hierarchyBounds(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new HierarchyBoundsEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<HierarchyEvent> hierarchy(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new HierarchyEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<InputMethodEvent> inputMethod(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new InputMethodEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<PropertyChangeEvent> propertyChange(@NonNull Component component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new PropertyChangeEventObservable(component, null));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<PropertyChangeEvent> propertyChange(@NonNull Component component, String propertyName) {
    ObjectHelper.requireNonNull(component, "component is null");
    ObjectHelper.requireNonNull(propertyName, "propertyName is null");
    return RxSwingPlugins.onAssembly(new PropertyChangeEventObservable(component, propertyName));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<DocumentEvent> document(@NonNull Document component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new DocumentEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<DocumentEvent> document(@NonNull JTextComponent component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return document(component.getDocument());
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<UndoableEditEvent> undoableEdit(@NonNull Document component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new UndoableEditEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<CaretEvent> caret(@NonNull JTextComponent component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new CaretEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<AncestorEvent> ancestor(@NonNull JComponent component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new AncestorEventObservable(component));
}
项目:RxJava2Swing    文件:SwingObservable.java   
@CheckReturnValue
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public static Observable<VetoablePropertyChangeEvent> vetoableChange(@NonNull JComponent component) {
    ObjectHelper.requireNonNull(component, "component is null");
    return RxSwingPlugins.onAssembly(new VetoableChangeEventObservable(component));
}