Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
hu.akarnokd.rxjava2.NbpObservable Maven / Gradle / Ivy
/**
* Copyright 2015 David Karnok and Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
* the License for the specific language governing permissions and limitations under the License.
*/
package hu.akarnokd.rxjava2;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.*;
import hu.akarnokd.rxjava2.Single.*;
import hu.akarnokd.rxjava2.annotations.*;
import hu.akarnokd.rxjava2.disposables.*;
import hu.akarnokd.rxjava2.functions.*;
import hu.akarnokd.rxjava2.internal.disposables.EmptyDisposable;
import hu.akarnokd.rxjava2.internal.functions.Functions;
import hu.akarnokd.rxjava2.internal.functions.Objects;
import hu.akarnokd.rxjava2.internal.operators.nbp.*;
import hu.akarnokd.rxjava2.internal.subscribers.nbp.*;
import hu.akarnokd.rxjava2.internal.util.Exceptions;
import hu.akarnokd.rxjava2.observables.nbp.*;
import hu.akarnokd.rxjava2.plugins.RxJavaPlugins;
import hu.akarnokd.rxjava2.schedulers.*;
import hu.akarnokd.rxjava2.subscribers.nbp.*;
/**
* Observable for delivering a sequence of values without backpressure.
* @param
*/
public class NbpObservable {
public interface NbpOnSubscribe extends Consumer> {
}
public interface NbpOperator extends Function, NbpSubscriber super Upstream>> {
}
public interface NbpSubscriber {
void onSubscribe(Disposable d);
void onNext(T value);
void onError(Throwable e);
void onComplete();
}
public interface NbpTransformer extends Function, NbpObservable> {
}
/** An empty observable instance as there is no need to instantiate this more than once. */
static final NbpObservable EMPTY = create(new NbpOnSubscribe() {
@Override
public void accept(NbpSubscriber super Object> s) {
s.onSubscribe(EmptyDisposable.INSTANCE);
s.onComplete();
}
});
/** A never NbpObservable instance as there is no need to instantiate this more than once. */
static final NbpObservable NEVER = create(new NbpOnSubscribe() {
@Override
public void accept(NbpSubscriber super Object> s) {
s.onSubscribe(EmptyDisposable.INSTANCE);
}
});
static final Object OBJECT = new Object();
public static NbpObservable amb(Iterable extends NbpObservable extends T>> sources) {
Objects.requireNonNull(sources, "sources is null");
return create(new NbpOnSubscribeAmb(null, sources));
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable amb(NbpObservable extends T>... sources) {
Objects.requireNonNull(sources, "sources is null");
int len = sources.length;
if (len == 0) {
return empty();
} else
if (len == 1) {
return (NbpObservable)sources[0];
}
return create(new NbpOnSubscribeAmb(sources, null));
}
/**
* Returns the default 'island' size or capacity-increment hint for unbounded buffers.
* @return
*/
static int bufferSize() {
return Observable.bufferSize();
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(Function super Object[], ? extends R> combiner, boolean delayError, int bufferSize, NbpObservable extends T>... sources) {
return combineLatest(sources, combiner, delayError, bufferSize);
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(Iterable extends NbpObservable extends T>> sources, Function super Object[], ? extends R> combiner) {
return combineLatest(sources, combiner, false, bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(Iterable extends NbpObservable extends T>> sources, Function super Object[], ? extends R> combiner, boolean delayError) {
return combineLatest(sources, combiner, delayError, bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(Iterable extends NbpObservable extends T>> sources, Function super Object[], ? extends R> combiner, boolean delayError, int bufferSize) {
Objects.requireNonNull(sources, "sources is null");
Objects.requireNonNull(combiner, "combiner is null");
validateBufferSize(bufferSize);
// the queue holds a pair of values so we need to double the capacity
int s = bufferSize << 1;
return create(new NbpOnSubscribeCombineLatest(null, sources, combiner, s, delayError));
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(NbpObservable extends T>[] sources, Function super Object[], ? extends R> combiner) {
return combineLatest(sources, combiner, false, bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(NbpObservable extends T>[] sources, Function super Object[], ? extends R> combiner, boolean delayError) {
return combineLatest(sources, combiner, delayError, bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(NbpObservable extends T>[] sources, Function super Object[], ? extends R> combiner, boolean delayError, int bufferSize) {
validateBufferSize(bufferSize);
Objects.requireNonNull(combiner, "combiner is null");
if (sources.length == 0) {
return empty();
}
// the queue holds a pair of values so we need to double the capacity
int s = bufferSize << 1;
return create(new NbpOnSubscribeCombineLatest(sources, null, combiner, s, delayError));
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
BiFunction super T1, ? super T2, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3,
Function3 super T1, ? super T2, ? super T3, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
Function4 super T1, ? super T2, ? super T3, ? super T4, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
NbpObservable extends T5> p5,
Function5 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4, p5);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
NbpObservable extends T5> p5, NbpObservable extends T6> p6,
Function6 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4, p5, p6);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
NbpObservable extends T5> p5, NbpObservable extends T6> p6,
NbpObservable extends T7> p7,
Function7 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4, p5, p6, p7);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
NbpObservable extends T5> p5, NbpObservable extends T6> p6,
NbpObservable extends T7> p7, NbpObservable extends T8> p8,
Function8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4, p5, p6, p7, p8);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable combineLatest(
NbpObservable extends T1> p1, NbpObservable extends T2> p2,
NbpObservable extends T3> p3, NbpObservable extends T4> p4,
NbpObservable extends T5> p5, NbpObservable extends T6> p6,
NbpObservable extends T7> p7, NbpObservable extends T8> p8,
NbpObservable extends T9> p9,
Function9 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> combiner) {
return combineLatest(Functions.toFunction(combiner), false, bufferSize(), p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(int prefetch, Iterable extends NbpObservable extends T>> sources) {
Objects.requireNonNull(sources, "sources is null");
return fromIterable(sources).concatMap((Function)Functions.identity(), prefetch);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(Iterable extends NbpObservable extends T>> sources) {
Objects.requireNonNull(sources, "sources is null");
return fromIterable(sources).concatMap((Function)Functions.identity());
}
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable concat(NbpObservable extends NbpObservable extends T>> sources) {
return concat(sources, bufferSize());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable concat(NbpObservable extends NbpObservable extends T>> sources, int bufferSize) {
return sources.concatMap((Function)Functions.identity());
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(NbpObservable extends T> p1, NbpObservable extends T> p2) {
return concatArray(p1, p2);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3) {
return concatArray(p1, p2, p3);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4) {
return concatArray(p1, p2, p3, p4);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4,
NbpObservable extends T> p5
) {
return concatArray(p1, p2, p3, p4, p5);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4,
NbpObservable extends T> p5, NbpObservable extends T> p6
) {
return concatArray(p1, p2, p3, p4, p5, p6);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4,
NbpObservable extends T> p5, NbpObservable extends T> p6,
NbpObservable extends T> p7
) {
return concatArray(p1, p2, p3, p4, p5, p6, p7);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4,
NbpObservable extends T> p5, NbpObservable extends T> p6,
NbpObservable extends T> p7, NbpObservable extends T> p8
) {
return concatArray(p1, p2, p3, p4, p5, p6, p7, p8);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concat(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4,
NbpObservable extends T> p5, NbpObservable extends T> p6,
NbpObservable extends T> p7, NbpObservable extends T> p8,
NbpObservable extends T> p9
) {
return concatArray(p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concatArray(int prefetch, NbpObservable extends T>... sources) {
Objects.requireNonNull(sources, "sources is null");
return fromArray(sources).concatMap((Function)Functions.identity(), prefetch);
}
/**
* Concatenates a variable number of NbpObservable sources.
*
* Note: named this way because of overload conflict with concat(NbpObservable<NbpObservable>)
* @param sources the array of sources
* @param the common base value type
* @return the new NbpObservable instance
* @throws NullPointerException if sources is null
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable concatArray(NbpObservable extends T>... sources) {
if (sources.length == 0) {
return empty();
} else
if (sources.length == 1) {
return (NbpObservable)sources[0];
}
return fromArray(sources).concatMap((Function)Functions.identity());
}
public static NbpObservable create(NbpOnSubscribe onSubscribe) {
Objects.requireNonNull(onSubscribe, "onSubscribe is null");
// TODO plugin wrapper
return new NbpObservable(onSubscribe);
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable defer(Supplier extends NbpObservable extends T>> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return create(new NbpOnSubscribeDefer(supplier));
}
@SchedulerSupport(SchedulerKind.NONE)
@SuppressWarnings("unchecked")
public static NbpObservable empty() {
return (NbpObservable)EMPTY;
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable error(Supplier extends Throwable> errorSupplier) {
Objects.requireNonNull(errorSupplier, "errorSupplier is null");
return create(new NbpOnSubscribeErrorSource(errorSupplier));
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable error(final Throwable e) {
Objects.requireNonNull(e, "e is null");
return error(new Supplier() {
@Override
public Throwable get() {
return e;
}
});
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable fromArray(T... values) {
Objects.requireNonNull(values, "values is null");
if (values.length == 0) {
return empty();
} else
if (values.length == 1) {
return just(values[0]);
}
return create(new NbpOnSubscribeArraySource(values));
}
// TODO match naming with RxJava 1.x
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable fromCallable(Callable extends T> supplier) {
Objects.requireNonNull(supplier, "supplier is null");
return create(new NbpOnSubscribeScalarAsyncSource(supplier));
}
/*
* It doesn't add cancellation support by default like 1.x
* if necessary, one can use composition to achieve it:
* futureObservable.doOnCancel(() -> future.cancel(true));
*/
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable fromFuture(Future extends T> future) {
Objects.requireNonNull(future, "future is null");
return create(new NbpOnSubscribeFutureSource(future, 0L, null));
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable fromFuture(Future extends T> future, long timeout, TimeUnit unit) {
Objects.requireNonNull(future, "future is null");
Objects.requireNonNull(unit, "unit is null");
NbpObservable o = create(new NbpOnSubscribeFutureSource(future, timeout, unit));
return o;
}
@SchedulerSupport(SchedulerKind.CUSTOM)
public static NbpObservable fromFuture(Future extends T> future, long timeout, TimeUnit unit, Scheduler scheduler) {
Objects.requireNonNull(scheduler, "scheduler is null");
NbpObservable o = fromFuture(future, timeout, unit);
return o.subscribeOn(scheduler);
}
@SchedulerSupport(SchedulerKind.IO)
public static NbpObservable fromFuture(Future extends T> future, Scheduler scheduler) {
Objects.requireNonNull(scheduler, "scheduler is null");
NbpObservable o = fromFuture(future);
return o.subscribeOn(Schedulers.io());
}
public static NbpObservable fromIterable(Iterable extends T> source) {
Objects.requireNonNull(source, "source is null");
return create(new NbpOnSubscribeIterableSource(source));
}
public static NbpObservable fromPublisher(final Publisher extends T> publisher) {
Objects.requireNonNull(publisher, "publisher is null");
return create(new NbpOnSubscribe() {
@Override
public void accept(final NbpSubscriber super T> s) {
publisher.subscribe(new Subscriber() {
@Override
public void onComplete() {
s.onComplete();
}
@Override
public void onError(Throwable t) {
s.onError(t);
}
@Override
public void onNext(T t) {
s.onNext(t);
}
@Override
public void onSubscribe(Subscription inner) {
s.onSubscribe(Disposables.from(inner));
inner.request(Long.MAX_VALUE);
}
});
}
});
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable generate(final Consumer> generator) {
Objects.requireNonNull(generator, "generator is null");
return generate(Functions.nullSupplier(),
new BiFunction, Object>() {
@Override
public Object apply(Object s, NbpSubscriber o) {
generator.accept(o);
return s;
}
}, Functions.emptyConsumer());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable generate(Supplier initialState, final BiConsumer> generator) {
Objects.requireNonNull(generator, "generator is null");
return generate(initialState, new BiFunction, S>() {
@Override
public S apply(S s, NbpSubscriber o) {
generator.accept(s, o);
return s;
}
}, Functions.emptyConsumer());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable generate(
final Supplier initialState,
final BiConsumer> generator,
Consumer super S> disposeState) {
Objects.requireNonNull(generator, "generator is null");
return generate(initialState, new BiFunction, S>() {
@Override
public S apply(S s, NbpSubscriber o) {
generator.accept(s, o);
return s;
}
}, disposeState);
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable generate(Supplier initialState, BiFunction, S> generator) {
return generate(initialState, generator, Functions.emptyConsumer());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable generate(Supplier initialState, BiFunction, S> generator, Consumer super S> disposeState) {
Objects.requireNonNull(initialState, "initialState is null");
Objects.requireNonNull(generator, "generator is null");
Objects.requireNonNull(disposeState, "diposeState is null");
return create(new NbpOnSubscribeGenerate(initialState, generator, disposeState));
}
@SchedulerSupport(SchedulerKind.COMPUTATION)
public static NbpObservable interval(long initialDelay, long period, TimeUnit unit) {
return interval(initialDelay, period, unit, Schedulers.computation());
}
@SchedulerSupport(SchedulerKind.CUSTOM)
public static NbpObservable interval(long initialDelay, long period, TimeUnit unit, Scheduler scheduler) {
if (initialDelay < 0) {
initialDelay = 0L;
}
if (period < 0) {
period = 0L;
}
Objects.requireNonNull(unit, "unit is null");
Objects.requireNonNull(scheduler, "scheduler is null");
return create(new NbpOnSubscribeIntervalSource(initialDelay, period, unit, scheduler));
}
@SchedulerSupport(SchedulerKind.COMPUTATION)
public static NbpObservable interval(long period, TimeUnit unit) {
return interval(period, period, unit, Schedulers.computation());
}
@SchedulerSupport(SchedulerKind.CUSTOM)
public static NbpObservable interval(long period, TimeUnit unit, Scheduler scheduler) {
return interval(period, period, unit, scheduler);
}
@SchedulerSupport(SchedulerKind.COMPUTATION)
public static NbpObservable intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit) {
return intervalRange(start, count, initialDelay, period, unit, Schedulers.computation());
}
@SchedulerSupport(SchedulerKind.CUSTOM)
public static NbpObservable intervalRange(long start, long count, long initialDelay, long period, TimeUnit unit, Scheduler scheduler) {
long end = start + (count - 1);
if (end < 0) {
throw new IllegalArgumentException("Overflow! start + count is bigger than Long.MAX_VALUE");
}
if (initialDelay < 0) {
initialDelay = 0L;
}
if (period < 0) {
period = 0L;
}
Objects.requireNonNull(unit, "unit is null");
Objects.requireNonNull(scheduler, "scheduler is null");
return create(new NbpOnSubscribeIntervalRangeSource(start, end, initialDelay, period, unit, scheduler));
}
public static NbpObservable just(T value) {
Objects.requireNonNull(value, "The value is null");
return new NbpObservableScalarSource(value);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
return fromArray(v1, v2);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
return fromArray(v1, v2, v3);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
return fromArray(v1, v2, v3, v4);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4, T v5) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
Objects.requireNonNull(v5, "The fifth value is null");
return fromArray(v1, v2, v3, v4, v5);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4, T v5, T v6) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
Objects.requireNonNull(v5, "The fifth value is null");
Objects.requireNonNull(v6, "The sixth value is null");
return fromArray(v1, v2, v3, v4, v5, v6);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4, T v5, T v6, T v7) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
Objects.requireNonNull(v5, "The fifth value is null");
Objects.requireNonNull(v6, "The sixth value is null");
Objects.requireNonNull(v7, "The seventh value is null");
return fromArray(v1, v2, v3, v4, v5, v6, v7);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
Objects.requireNonNull(v5, "The fifth value is null");
Objects.requireNonNull(v6, "The sixth value is null");
Objects.requireNonNull(v7, "The seventh value is null");
Objects.requireNonNull(v8, "The eigth value is null");
return fromArray(v1, v2, v3, v4, v5, v6, v7, v8);
}
@SuppressWarnings("unchecked")
@SchedulerSupport(SchedulerKind.NONE)
public static final NbpObservable just(T v1, T v2, T v3, T v4, T v5, T v6, T v7, T v8, T v9) {
Objects.requireNonNull(v1, "The first value is null");
Objects.requireNonNull(v2, "The second value is null");
Objects.requireNonNull(v3, "The third value is null");
Objects.requireNonNull(v4, "The fourth value is null");
Objects.requireNonNull(v5, "The fifth value is null");
Objects.requireNonNull(v6, "The sixth value is null");
Objects.requireNonNull(v7, "The seventh value is null");
Objects.requireNonNull(v8, "The eigth value is null");
Objects.requireNonNull(v9, "The ninth is null");
return fromArray(v1, v2, v3, v4, v5, v6, v7, v8, v9);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(int maxConcurrency, int bufferSize, Iterable extends NbpObservable extends T>> sources) {
return fromIterable(sources).flatMap((Function)Functions.identity(), false, maxConcurrency, bufferSize);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(int maxConcurrency, int bufferSize, NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), false, maxConcurrency, bufferSize);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(int maxConcurrency, NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(Iterable extends NbpObservable extends T>> sources) {
return fromIterable(sources).flatMap((Function)Functions.identity());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(Iterable extends NbpObservable extends T>> sources, int maxConcurrency) {
return fromIterable(sources).flatMap((Function)Functions.identity(), maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static NbpObservable merge(NbpObservable extends NbpObservable extends T>> sources) {
return sources.flatMap((Function)Functions.identity());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(NbpObservable extends NbpObservable extends T>> sources, int maxConcurrency) {
return sources.flatMap((Function)Functions.identity(), maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(NbpObservable extends T> p1, NbpObservable extends T> p2) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
return fromArray(p1, p2).flatMap((Function)Functions.identity(), false, 2);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(NbpObservable extends T> p1, NbpObservable extends T> p2, NbpObservable extends T> p3) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
Objects.requireNonNull(p3, "p3 is null");
return fromArray(p1, p2, p3).flatMap((Function)Functions.identity(), false, 3);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
Objects.requireNonNull(p3, "p3 is null");
Objects.requireNonNull(p4, "p4 is null");
return fromArray(p1, p2, p3, p4).flatMap((Function)Functions.identity(), false, 4);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable merge(NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), sources.length);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(boolean delayErrors, Iterable extends NbpObservable extends T>> sources) {
return fromIterable(sources).flatMap((Function)Functions.identity(), true);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(int maxConcurrency, int bufferSize, Iterable extends NbpObservable extends T>> sources) {
return fromIterable(sources).flatMap((Function)Functions.identity(), true, maxConcurrency, bufferSize);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(int maxConcurrency, int bufferSize, NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), true, maxConcurrency, bufferSize);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(int maxConcurrency, Iterable extends NbpObservable extends T>> sources) {
return fromIterable(sources).flatMap((Function)Functions.identity(), true, maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(int maxConcurrency, NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), true, maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static NbpObservable mergeDelayError(NbpObservable extends NbpObservable extends T>> sources) {
return sources.flatMap((Function)Functions.identity(), true);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(NbpObservable extends NbpObservable extends T>> sources, int maxConcurrency) {
return sources.flatMap((Function)Functions.identity(), true, maxConcurrency);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(NbpObservable extends T> p1, NbpObservable extends T> p2) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
return fromArray(p1, p2).flatMap((Function)Functions.identity(), true, 2);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(NbpObservable extends T> p1, NbpObservable extends T> p2, NbpObservable extends T> p3) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
Objects.requireNonNull(p3, "p3 is null");
return fromArray(p1, p2, p3).flatMap((Function)Functions.identity(), true, 3);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(
NbpObservable extends T> p1, NbpObservable extends T> p2,
NbpObservable extends T> p3, NbpObservable extends T> p4) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
Objects.requireNonNull(p3, "p3 is null");
Objects.requireNonNull(p4, "p4 is null");
return fromArray(p1, p2, p3, p4).flatMap((Function)Functions.identity(), true, 4);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable mergeDelayError(NbpObservable extends T>... sources) {
return fromArray(sources).flatMap((Function)Functions.identity(), true, sources.length);
}
@SchedulerSupport(SchedulerKind.NONE)
@SuppressWarnings("unchecked")
public static NbpObservable never() {
return (NbpObservable)NEVER;
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable range(final int start, final int count) {
if (count < 0) {
throw new IllegalArgumentException("count >= required but it was " + count);
} else
if (count == 0) {
return empty();
} else
if (count == 1) {
return just(start);
} else
if ((long)start + (count - 1) > Integer.MAX_VALUE) {
throw new IllegalArgumentException("Integer overflow");
}
return create(new NbpOnSubscribe() {
@Override
public void accept(NbpSubscriber super Integer> s) {
BooleanDisposable d = new BooleanDisposable();
s.onSubscribe(d);
long end = start - 1L + count;
for (long i = start; i <= end && !d.isDisposed(); i++) {
s.onNext((int)i);
}
if (!d.isDisposed()) {
s.onComplete();
}
}
});
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable sequenceEqual(NbpObservable extends T> p1, NbpObservable extends T> p2) {
return sequenceEqual(p1, p2, Objects.equalsPredicate(), bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable sequenceEqual(NbpObservable extends T> p1, NbpObservable extends T> p2, BiPredicate super T, ? super T> isEqual) {
return sequenceEqual(p1, p2, isEqual, bufferSize());
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable sequenceEqual(NbpObservable extends T> p1, NbpObservable extends T> p2, BiPredicate super T, ? super T> isEqual, int bufferSize) {
Objects.requireNonNull(p1, "p1 is null");
Objects.requireNonNull(p2, "p2 is null");
Objects.requireNonNull(isEqual, "isEqual is null");
validateBufferSize(bufferSize);
return create(new NbpOnSubscribeSequenceEqual(p1, p2, isEqual, bufferSize));
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable sequenceEqual(NbpObservable extends T> p1, NbpObservable extends T> p2, int bufferSize) {
return sequenceEqual(p1, p2, Objects.equalsPredicate(), bufferSize);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable switchOnNext(int bufferSize, NbpObservable extends NbpObservable extends T>> sources) {
return sources.switchMap((Function)Functions.identity(), bufferSize);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable switchOnNext(NbpObservable extends NbpObservable extends T>> sources) {
return sources.switchMap((Function)Functions.identity());
}
@SchedulerSupport(SchedulerKind.COMPUTATION)
public static NbpObservable timer(long delay, TimeUnit unit) {
return timer(delay, unit, Schedulers.computation());
}
@SchedulerSupport(SchedulerKind.CUSTOM)
public static NbpObservable timer(long delay, TimeUnit unit, Scheduler scheduler) {
if (delay < 0) {
delay = 0L;
}
Objects.requireNonNull(unit, "unit is null");
Objects.requireNonNull(scheduler, "scheduler is null");
return create(new NbpOnSubscribeTimerOnceSource(delay, unit, scheduler));
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable using(Supplier extends D> resourceSupplier, Function super D, ? extends NbpObservable extends T>> sourceSupplier, Consumer super D> disposer) {
return using(resourceSupplier, sourceSupplier, disposer, true);
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable using(Supplier extends D> resourceSupplier, Function super D, ? extends NbpObservable extends T>> sourceSupplier, Consumer super D> disposer, boolean eager) {
Objects.requireNonNull(resourceSupplier, "resourceSupplier is null");
Objects.requireNonNull(sourceSupplier, "sourceSupplier is null");
Objects.requireNonNull(disposer, "disposer is null");
return create(new NbpOnSubscribeUsing(resourceSupplier, sourceSupplier, disposer, eager));
}
private static void validateBufferSize(int bufferSize) {
if (bufferSize <= 0) {
throw new IllegalArgumentException("bufferSize > 0 required but it was " + bufferSize);
}
}
@SchedulerSupport(SchedulerKind.NONE)
public static NbpObservable zip(Iterable extends NbpObservable extends T>> sources, Function super Object[], ? extends R> zipper) {
Objects.requireNonNull(zipper, "zipper is null");
Objects.requireNonNull(sources, "sources is null");
return create(new NbpOnSubscribeZip