Java Code Examples for io.reactivex.internal.functions.ObjectHelper#requireNonNull()

The following examples show how to use io.reactivex.internal.functions.ObjectHelper#requireNonNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceFlowableToFlowable.java    From akarnokd-misc with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: SingleLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public final Disposable subscribe(final Consumer<? super T> onSuccess, final Consumer<? super Throwable> onError) {
    ObjectHelper.requireNonNull(onSuccess, "onSuccess is null");
    ObjectHelper.requireNonNull(onError, "onError is null");

    ConsumerSingleObserver<T> observer = new ConsumerSingleObserver<T>(onSuccess, onError);
    subscribe(observer);
    return observer;
}
 
Example 3
Source File: FlowableLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public final Disposable subscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError,
                                  Action onComplete, Consumer<? super Subscription> onSubscribe) {
    ObjectHelper.requireNonNull(onNext, "onNext is null");
    ObjectHelper.requireNonNull(onError, "onError is null");
    ObjectHelper.requireNonNull(onComplete, "onComplete is null");
    ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");

    LambdaSubscriber<T> ls = new LambdaSubscriber<T>(onNext, onError, onComplete, onSubscribe);

    subscribe(ls);

    return ls;
}
 
Example 4
Source File: MaybeLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public final Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super Throwable> onError,
                                  Action onComplete) {
    ObjectHelper.requireNonNull(onSuccess, "onSuccess is null");
    ObjectHelper.requireNonNull(onError, "onError is null");
    ObjectHelper.requireNonNull(onComplete, "onComplete is null");
    return subscribeWith(new MaybeCallbackObserver<T>(onSuccess, onError, onComplete));
}
 
Example 5
Source File: CompletableLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public final Disposable subscribe(final Action onComplete) {
    ObjectHelper.requireNonNull(onComplete, "onComplete is null");

    CallbackCompletableObserver observer = new CallbackCompletableObserver(onComplete);
    subscribe(observer);
    return observer;
}
 
Example 6
Source File: FlowableUtils.java    From RxBus with Apache License 2.0 5 votes vote down vote up
private static <T> Disposable subscribe(Flowable<T> flowable,
                                        Consumer<? super T> onNext,
                                        Consumer<? super Throwable> onError,
                                        Action onComplete,
                                        Consumer<? super Subscription> onSubscribe) {
    ObjectHelper.requireNonNull(flowable, "flowable is null");
    ObjectHelper.requireNonNull(onNext, "onNext is null");
    ObjectHelper.requireNonNull(onError, "onError is null");
    ObjectHelper.requireNonNull(onComplete, "onComplete is null");
    ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");

    MyLambdaSubscriber<T> ls = new MyLambdaSubscriber<T>(onNext, onError, onComplete, onSubscribe);
    flowable.subscribe(ls);
    return ls;
}
 
Example 7
Source File: JSONArrayObservable.java    From Tangram-Android with MIT License 5 votes vote down vote up
public static <T> Observable<T> fromJsonArray(JSONArray json) {
    ObjectHelper.requireNonNull(json, "items is null");
    if (json.length() == 0) {
        return empty();
    }
    return RxJavaPlugins.onAssembly(new JSONArrayObservable<T>(json));
}
 
Example 8
Source File: ObservableLife.java    From rxjava-RxLife with Apache License 2.0 5 votes vote down vote up
public final Disposable subscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError,
                                  Action onComplete, Consumer<? super Disposable> onSubscribe) {
    ObjectHelper.requireNonNull(onNext, "onNext is null");
    ObjectHelper.requireNonNull(onError, "onError is null");
    ObjectHelper.requireNonNull(onComplete, "onComplete is null");
    ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");

    LambdaObserver<T> ls = new LambdaObserver<T>(onNext, onError, onComplete, onSubscribe);

    subscribe(ls);

    return ls;
}
 
Example 9
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 5 votes vote down vote up
@SafeVarargs
public static <T> ResourceFlowable<T> fromArray(Consumer<? super T> release, T... items) {
    ObjectHelper.requireNonNull(release, "release is null");
    int n = items.length;
    if (n == 1) {
        return just(items[0], release);
    }
    return new ResourceFlowableArray<>(items, release);
}
 
Example 10
Source File: RxBus.java    From RxBus with Apache License 2.0 5 votes vote down vote up
public void unregister(@NonNull Object observer) {
    ObjectHelper.requireNonNull(observer, "Observer to unregister must not be null.");
    CompositeDisposable composite = OBSERVERS.get(observer.getClass());
    ObjectHelper.requireNonNull(composite, "Missing observer, it was registered?");
    composite.dispose();
    OBSERVERS.remove(observer.getClass());

    Set<CustomSubscriber<?>> subscribers = SUBSCRIBERS.get(observer.getClass());
    if (subscribers != null) {
        subscribers.clear();
        SUBSCRIBERS.remove(observer.getClass());
    }
}
 
Example 11
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final ResourceFlowable<T> observeOn(ResourceScheduler scheduler) {
    ObjectHelper.requireNonNull(scheduler, "scheduler is null");
    return new ResourceFlowableObserveOn<>(this, scheduler, Flowable.bufferSize());
}
 
Example 12
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final ResourceFlowable<T> withRelease(Consumer<? super T> release) {
    ObjectHelper.requireNonNull(release, "release is null");
    return new ResourceFlowableWithRelease<>(this, release);
}
 
Example 13
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final ResourceFlowable<T> subscribeOn(ResourceScheduler scheduler) {
    ObjectHelper.requireNonNull(scheduler, "scheduler is null");
    // TODO
    throw new UnsupportedOperationException();
}
 
Example 14
Source File: CustomSubscriber.java    From RxBus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("WeakerAccess")
public CustomSubscriber<T> withFilter(@NonNull Predicate<T> filter) {
    ObjectHelper.requireNonNull(filter, "Filter must not be null.");
    this.filter = filter;
    return this;
}
 
Example 15
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final <R> ResourceFlowable<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> mapper, Consumer<? super R> release) {
    ObjectHelper.requireNonNull(mapper, "mapper is null");
    ObjectHelper.requireNonNull(release, "release is null");
    // TODO
    throw new UnsupportedOperationException();
}
 
Example 16
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public static <T> ResourceFlowable<T> just(T item, Consumer<? super T> release) {
    ObjectHelper.requireNonNull(item, "item is null");
    ObjectHelper.requireNonNull(release, "release is null");
    return new ResourceFlowableJust<>(item, release);
}
 
Example 17
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final <R> ResourceFlowable<R> flatMap(Function<? super T, ? extends ResourceFlowable<? extends R>> mapper) {
    ObjectHelper.requireNonNull(mapper, "mapper is null");
    // TODO
    throw new UnsupportedOperationException();
}
 
Example 18
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public final <R> Flowable<R> toFlowable(Function<? super T, ? extends R> extract) {
    ObjectHelper.requireNonNull(extract, "extract is null");
    return new ResourceFlowableToFlowable<>(this, extract);
}
 
Example 19
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public static <T> ResourceFlowable<T> fromIterable(Iterable<? extends T> items, Consumer<? super T> release) {
    ObjectHelper.requireNonNull(items, "items is null");
    ObjectHelper.requireNonNull(release, "release is null");
    return new ResourceFlowableIterable<>(items, release);
}
 
Example 20
Source File: ResourceFlowable.java    From akarnokd-misc with Apache License 2.0 4 votes vote down vote up
public static <T> ResourceFlowable<T> fromPublisher(Publisher<? extends T> source, Consumer<? super T> release) {
    ObjectHelper.requireNonNull(source, "source is null");
    ObjectHelper.requireNonNull(release, "release is null");
    return new ResourceFlowablePublisher<>(source, release);
}