public abstract class

Maybe

extends Object
implements MaybeSource<T>
java.lang.Object
   ↳ io.reactivex.Maybe<T>
Known Direct Subclasses

Class Overview

Represents a deferred computation and emission of a maybe value or exception.

The main consumer type of Maybe is MaybeObserver whose methods are called in a sequential fashion following this protocol:
onSubscribe (onSuccess | onError | onComplete)?.

Summary

Public Constructors
Maybe()
Public Methods
static <T> Maybe<T> amb(Iterable<? extends MaybeSource<? extends T>> sources)
Runs multiple Maybe sources and signals the events of the first one that signals (cancelling the rest).
static <T> Maybe<T> ambArray(MaybeSource...<? extends T> sources)
Runs multiple Maybe sources and signals the events of the first one that signals (cancelling the rest).
final Maybe<T> ambWith(MaybeSource<? extends T> other)
Mirrors the MaybeSource (current or provided) that first signals an event.
final T blockingGet(T defaultValue)
Waits in a blocking fashion until the current Maybe signals a success value (which is returned), defaultValue if completed or an exception (which is propagated).
final T blockingGet()
Waits in a blocking fashion until the current Maybe signals a success value (which is returned), null if completed or an exception (which is propagated).
final Maybe<T> cache()
Returns a Maybe that subscribes to this Maybe lazily, caches its event and replays it, to all the downstream subscribers.
final <U> Maybe<U> cast(Class<? extends U> clazz)
Casts the success value of the current Maybe into the target type or signals a ClassCastException if not compatible.
final <R> Maybe<R> compose(MaybeTransformer<? super T, ? extends R> transformer)
Transform a Maybe by applying a particular Transformer function to it.
static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
Returns a Flowable that emits the items emitted by two MaybeSources, one after the other.
static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)
Returns a Flowable that emits the items emitted by three MaybeSources, one after the other.
static <T> Flowable<T> concat(Iterable<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by an Iterable sequence.
static <T> Flowable<T> concat(Publisher<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by a Publisher sequence.
static <T> Flowable<T> concat(Publisher<? extends MaybeSource<? extends T>> sources, int prefetch)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by a Publisher sequence.
static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)
Returns a Flowable that emits the items emitted by four MaybeSources, one after the other.
static <T> Flowable<T> concatArray(MaybeSource...<? extends T> sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources in the array.
static <T> Flowable<T> concatArrayDelayError(MaybeSource...<? extends T> sources)
Concatenates a variable number of MaybeSource sources and delays errors from any of them till all terminate.
static <T> Flowable<T> concatArrayEager(MaybeSource...<? extends T> sources)
Concatenates a sequence of MaybeSource eagerly into a single stream of values.
static <T> Flowable<T> concatDelayError(Publisher<? extends MaybeSource<? extends T>> sources)
Concatenates the Publisher sequence of Publishers into a single sequence by subscribing to each inner Publisher, one after the other, one at a time and delays any errors till the all inner and the outer Publishers terminate.
static <T> Flowable<T> concatDelayError(Iterable<? extends MaybeSource<? extends T>> sources)
Concatenates the Iterable sequence of MaybeSources into a single sequence by subscribing to each MaybeSource, one after the other, one at a time and delays any errors till the all inner MaybeSources terminate.
static <T> Flowable<T> concatEager(Iterable<? extends MaybeSource<? extends T>> sources)
Concatenates a sequence of MaybeSources eagerly into a single stream of values.
static <T> Flowable<T> concatEager(Publisher<? extends MaybeSource<? extends T>> sources)
Concatenates a Publisher sequence of Publishers eagerly into a single stream of values.
final <R> Maybe<R> concatMap(Function<? super T, ? extends MaybeSource<? extends R>> mapper)
Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe, where that function returns a MaybeSource.
final Flowable<T> concatWith(MaybeSource<? extends T> other)
Returns a Flowable that emits the items emitted from the current MaybeSource, then the next, one after the other, without interleaving them.
final Single<Boolean> contains(Object item)
Returns a Single that emits a Boolean that indicates whether the source Maybe emitted a specified item.
final Single<Long> count()
Returns a Maybe that counts the total number of items emitted (0 or 1) by the source Maybe and emits this count as a 64-bit Long.
static <T> Maybe<T> create(MaybeOnSubscribe<T> onSubscribe)
Provides an API (via a cold Maybe) that bridges the reactive world with the callback-style world.
final Maybe<T> defaultIfEmpty(T defaultItem)
Returns a Maybe that emits the item emitted by the source Maybe or a specified default item if the source Maybe is empty.
static <T> Maybe<T> defer(Callable<? extends MaybeSource<? extends T>> maybeSupplier)
Calls a Callable for each individual MaybeObserver to return the actual MaybeSource source to be subscribed to.
final <U, V> Maybe<T> delay(Publisher<U> delayIndicator)
Delays the emission of this Maybe until the given Publisher signals an item or completes.
final Maybe<T> delay(long delay, TimeUnit unit)
Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a specified delay.
final Maybe<T> delay(long delay, TimeUnit unit, Scheduler scheduler)
Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a specified delay running on the specified Scheduler.
final <U> Maybe<T> delaySubscription(Publisher<U> subscriptionIndicator)
Returns a Maybe that delays the subscription to this Maybe until the other Publisher emits an element or completes normally.
final Maybe<T> delaySubscription(long delay, TimeUnit unit, Scheduler scheduler)
Returns a Maybe that delays the subscription to the source Maybe by a given amount of time, both waiting and subscribing on a given Scheduler.
final Maybe<T> delaySubscription(long delay, TimeUnit unit)
Returns a Maybe that delays the subscription to the source Maybe by a given amount of time.
final Maybe<T> doAfterSuccess(Consumer<? super T> onAfterSuccess)
Calls the specified consumer with the success item after this item has been emitted to the downstream.
final Maybe<T> doAfterTerminate(Action onAfterTerminate)
Registers an Action to be called when this Maybe invokes either onSuccess, onComplete or onError.
final Maybe<T> doFinally(Action onFinally)
Calls the specified action after this Maybe signals onSuccess, onError or onComplete or gets disposed by the downstream.
final Maybe<T> doOnComplete(Action onComplete)
Modifies the source Maybe so that it invokes an action when it calls onComplete.
final Maybe<T> doOnDispose(Action onDispose)
Calls the shared Action if a MaybeObserver subscribed to the current Maybe disposes the common Disposable it received via onSubscribe.
final Maybe<T> doOnError(Consumer<? super Throwable> onError)
Calls the shared consumer with the error sent via onError for each MaybeObserver that subscribes to the current Maybe.
final Maybe<T> doOnEvent(BiConsumer<? super T, ? super Throwable> onEvent)
Calls the given onEvent callback with the (success value, null) for an onSuccess, (null, throwable) for an onError or (null, null) for an onComplete signal from this Maybe before delivering said signal to the downstream.
final Maybe<T> doOnSubscribe(Consumer<? super Disposable> onSubscribe)
Calls the shared consumer with the Disposable sent through the onSubscribe for each MaybeObserver that subscribes to the current Maybe.
final Maybe<T> doOnSuccess(Consumer<? super T> onSuccess)
Calls the shared consumer with the success value sent via onSuccess for each MaybeObserver that subscribes to the current Maybe.
static <T> Maybe<T> empty()
Returns a (singleton) Maybe instance that calls onComplete immediately.
static <T> Maybe<T> error(Throwable exception)
Returns a Maybe that invokes a subscriber's onError method when the subscriber subscribes to it.
static <T> Maybe<T> error(Callable<? extends Throwable> supplier)
Returns a Maybe that invokes a MaybeObserver's onError method when the MaybeObserver subscribes to it.
final Maybe<T> filter(Predicate<? super T> predicate)
Filters the success item of the Maybe via a predicate function and emitting it if the predicate returns true, completing otherwise.
final <U, R> Maybe<R> flatMap(Function<? super T, ? extends MaybeSource<? extends U>> mapper, BiFunction<? super T, ? super U, ? extends R> resultSelector)
Returns a Maybe that emits the results of a specified function to the pair of values emitted by the source Maybe and a specified mapped MaybeSource.
final <R> Maybe<R> flatMap(Function<? super T, ? extends MaybeSource<? extends R>> onSuccessMapper, Function<? super Throwable, ? extends MaybeSource<? extends R>> onErrorMapper, Callable<? extends MaybeSource<? extends R>> onCompleteSupplier)
Maps the onSuccess, onError or onComplete signals of this Maybe into MaybeSource and emits that MaybeSource's signals

Scheduler:
flatMap does not operate by default on a particular Scheduler.
final <R> Maybe<R> flatMap(Function<? super T, ? extends MaybeSource<? extends R>> mapper)
Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe, where that function returns a MaybeSource.
final Completable flatMapCompletable(Function<? super T, ? extends CompletableSource> mapper)
Returns a Completable that completes based on applying a specified function to the item emitted by the source Maybe, where that function returns a Completable.
final <R> Observable<R> flatMapObservable(Function<? super T, ? extends ObservableSource<? extends R>> mapper)
Returns an Observable that is based on applying a specified function to the item emitted by the source Maybe, where that function returns an ObservableSource.
final <R> Flowable<R> flatMapPublisher(Function<? super T, ? extends Publisher<? extends R>> mapper)
Returns a Flowable that emits items based on applying a specified function to the item emitted by the source Maybe, where that function returns a Publisher.
final <R> Single<R> flatMapSingle(Function<? super T, ? extends SingleSource<? extends R>> mapper)
Returns a Single based on applying a specified function to the item emitted by the source Maybe, where that function returns a Single.
final <R> Maybe<R> flatMapSingleElement(Function<? super T, ? extends SingleSource<? extends R>> mapper)
Returns a Maybe based on applying a specified function to the item emitted by the source Maybe, where that function returns a Single.
final <U> Flowable<U> flattenAsFlowable(Function<? super T, ? extends Iterable<? extends U>> mapper)
Returns a Flowable that merges each item emitted by the source Maybe with the values in an Iterable corresponding to that item that is generated by a selector.
final <U> Observable<U> flattenAsObservable(Function<? super T, ? extends Iterable<? extends U>> mapper)
Returns an Observable that maps a success value into an Iterable and emits its items.
static <T> Maybe<T> fromAction(Action run)
Returns a Maybe instance that runs the given Action for each subscriber and emits either its exception or simply completes.
static <T> Maybe<T> fromCallable(Callable<? extends T> callable)
Returns a Maybe that invokes passed function and emits its result for each new MaybeObserver that subscribes while considering null value from the callable as indication for valueless completion.
static <T> Maybe<T> fromCompletable(CompletableSource completableSource)
Wraps a CompletableSource into a Maybe.
static <T> Maybe<T> fromFuture(Future<? extends T> future)
Converts a Future into a Maybe, treating a null result as an indication of emptiness.
static <T> Maybe<T> fromFuture(Future<? extends T> future, long timeout, TimeUnit unit)
Converts a Future into a Maybe, with a timeout on the Future.
static <T> Maybe<T> fromRunnable(Runnable run)
Returns a Maybe instance that runs the given Action for each subscriber and emits either its exception or simply completes.
static <T> Maybe<T> fromSingle(SingleSource<T> singleSource)
Wraps a SingleSource into a Maybe.
final Maybe<T> hide()
Hides the identity of this Maybe and its Disposable.
final Completable ignoreElement()
Ignores the item emitted by the source Maybe and only calls onComplete or onError.
final Single<Boolean> isEmpty()
Returns a Single that emits true if the source Maybe is empty, otherwise false.
static <T> Maybe<T> just(T item)
Returns a Maybe that emits a specified item.
final <R> Maybe<R> lift(MaybeOperator<? extends R, ? super T> lift)
Lifts a function to the current Maybe and returns a new Maybe that when subscribed to will pass the values of the current Maybe through the MaybeOperator function.
final <R> Maybe<R> map(Function<? super T, ? extends R> mapper)
Returns a Maybe that applies a specified function to the item emitted by the source Maybe and emits the result of this function application.
static <T> Maybe<T> merge(MaybeSource<? extends MaybeSource<? extends T>> source)
Flattens a MaybeSource that emits a MaybeSource into a single MaybeSource that emits the item emitted by the nested MaybeSource, without any transformation.
static <T> Flowable<T> merge(Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence, running at most maxConcurrency MaybeSources at once.
static <T> Flowable<T> merge(Publisher<? extends MaybeSource<? extends T>> sources)
Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.
static <T> Flowable<T> merge(Iterable<? extends MaybeSource<? extends T>> sources)
Merges an Iterable sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.
static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
Flattens two MaybeSources into a single Flowable, without any transformation.
static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)
Flattens four MaybeSources into a single Flowable, without any transformation.
static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)
Flattens three MaybeSources into a single Flowable, without any transformation.
static <T> Flowable<T> mergeArray(MaybeSource...<? extends T> sources)
Merges an array sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.
static <T> Flowable<T> mergeArrayDelayError(MaybeSource...<? extends T> sources)
Flattens an array of MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.
static <T> Flowable<T> mergeDelayError(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)
Flattens three MaybeSource into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from all of the source MaybeSources without being interrupted by an error notification from one of them.
static <T> Flowable<T> mergeDelayError(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)
Flattens four MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from all of the source MaybeSources without being interrupted by an error notification from one of them.
static <T> Flowable<T> mergeDelayError(Iterable<? extends MaybeSource<? extends T>> sources)
Flattens an Iterable of MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.
static <T> Flowable<T> mergeDelayError(Publisher<? extends MaybeSource<? extends T>> sources)
Flattens a Publisher that emits MaybeSources into one Publisher, in a way that allows a Subscriber to receive all successfully emitted items from all of the source Publishers without being interrupted by an error notification from one of them.
static <T> Flowable<T> mergeDelayError(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
Flattens two MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.
final Flowable<T> mergeWith(MaybeSource<? extends T> other)
Flattens this and another Maybe into a single Flowable, without any transformation.
static <T> Maybe<T> never()
Returns a Maybe that never sends any items or notifications to a MaybeObserver.
final Maybe<T> observeOn(Scheduler scheduler)
Wraps a Maybe to emit its item (or notify of its error) on a specified Scheduler, asynchronously.
final <U> Maybe<U> ofType(Class<U> clazz)
Filters the items emitted by a Maybe, only emitting its success value if that is an instance of the supplied Class.
final Maybe<T> onErrorComplete(Predicate<? super Throwable> predicate)
Returns a Maybe instance that if this Maybe emits an error and the predicate returns true, it will emit an onComplete and swallow the throwable.
final Maybe<T> onErrorComplete()
Returns a Maybe instance that if this Maybe emits an error, it will emit an onComplete and swallow the throwable.
final Maybe<T> onErrorResumeNext(Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction)
Instructs a Maybe to pass control to another Maybe rather than invoking onError if it encounters an error.
final Maybe<T> onErrorResumeNext(MaybeSource<? extends T> next)
Instructs a Maybe to pass control to another MaybeSource rather than invoking onError if it encounters an error.
final Maybe<T> onErrorReturn(Function<? super Throwable, ? extends T> valueSupplier)
Instructs a Maybe to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.
final Maybe<T> onErrorReturnItem(T item)
Instructs a Maybe to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.
final Maybe<T> onExceptionResumeNext(MaybeSource<? extends T> next)
Instructs a Maybe to pass control to another MaybeSource rather than invoking onError if it encounters an Exception.
final Maybe<T> onTerminateDetach()
Nulls out references to the upstream producer and downstream MaybeObserver if the sequence is terminated or downstream calls dispose().
final Flowable<T> repeat()
Returns a Flowable that repeats the sequence of items emitted by the source Maybe indefinitely.
final Flowable<T> repeat(long times)
Returns a Flowable that repeats the sequence of items emitted by the source Maybe at most count times.
final Flowable<T> repeatUntil(BooleanSupplier stop)
Returns a Flowable that repeats the sequence of items emitted by the source Maybe until the provided stop function returns true.
final Flowable<T> repeatWhen(Function<? super Flowable<Object>, ? extends Publisher<?>> handler)
Returns a Flowable that emits the same values as the source Publisher with the exception of an onComplete.
final Maybe<T> retry(long times, Predicate<? super Throwable> predicate)
Retries at most times or until the predicate returns false, whichever happens first.
final Maybe<T> retry(BiPredicate<? super Integer, ? super Throwable> predicate)
Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError and the predicate returns true for that specific exception and retry count.
final Maybe<T> retry(Predicate<? super Throwable> predicate)
Retries the current Maybe if it fails and the predicate returns true.
final Maybe<T> retry()
Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError (infinite retry count).
final Maybe<T> retry(long count)
Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError up to a specified number of retries.
final Maybe<T> retryUntil(BooleanSupplier stop)
Retries until the given stop function returns true.
final Maybe<T> retryWhen(Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler)
Returns a Maybe that emits the same values as the source Maybe with the exception of an onError.
static <T> Single<Boolean> sequenceEqual(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
Returns a Single that emits a Boolean value that indicates whether two MaybeSource sequences are the same by comparing the items emitted by each MaybeSource pairwise.
static <T> Single<Boolean> sequenceEqual(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, BiPredicate<? super T, ? super T> isEqual)
Returns a Single that emits a Boolean value that indicates whether two MaybeSources are the same by comparing the items emitted by each MaybeSource pairwise based on the results of a specified equality function.
final void subscribe(MaybeObserver<? super T> observer)
Subscribes the given MaybeObserver to this MaybeSource instance.
final Disposable subscribe(Consumer<? super T> onSuccess)
Subscribes to a Maybe and provides a callback to handle the items it emits.
final Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super Throwable> onError, Action onComplete)
Subscribes to a Maybe and provides callbacks to handle the items it emits and any error or completion notification it issues.
final Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super Throwable> onError)
Subscribes to a Maybe and provides callbacks to handle the items it emits and any error notification it issues.
final Disposable subscribe()
Subscribes to a Maybe and ignores onSuccess and onComplete emissions.
final Maybe<T> subscribeOn(Scheduler scheduler)
Asynchronously subscribes subscribers to this Maybe on the specified Scheduler.
final <E extends MaybeObserver<? super T>> E subscribeWith(E observer)
Subscribes a given MaybeObserver (subclass) to this Maybe and returns the given MaybeObserver as is.
final Maybe<T> switchIfEmpty(MaybeSource<? extends T> other)
Returns a Maybe that emits the items emitted by the source Maybe or the items of an alternate MaybeSource if the current Maybe is empty.
final <U> Maybe<T> takeUntil(Publisher<U> other)
Returns a Maybe that emits the item emitted by the source Maybe until a second Publisher emits an item.
final <U> Maybe<T> takeUntil(MaybeSource<U> other)
Returns a Maybe that emits the items emitted by the source Maybe until a second MaybeSource emits an item.
final TestObserver<T> test(boolean cancelled)
Creates a TestObserver optionally in cancelled state, then subscribes it to this Maybe.
final TestObserver<T> test()
Creates a TestObserver and subscribes it to this Maybe.
final Maybe<T> timeout(long timeout, TimeUnit timeUnit)
Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item.
final <U> Maybe<T> timeout(Publisher<U> timeoutIndicator, MaybeSource<? extends T> fallback)
If the current Maybe source didn't signal an event before the timeoutIndicator Publisher signals, the current Maybe is cancelled and the fallback MaybeSource subscribed to as a continuation.
final <U> Maybe<T> timeout(MaybeSource<U> timeoutIndicator, MaybeSource<? extends T> fallback)
If the current Maybe source didn't signal an event before the timeoutIndicator MaybeSource signals, the current Maybe is cancelled and the fallback MaybeSource subscribed to as a continuation.
final Maybe<T> timeout(long timeout, TimeUnit timeUnit, MaybeSource<? extends T> fallback)
Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item.
final <U> Maybe<T> timeout(MaybeSource<U> timeoutIndicator)
If this Maybe source didn't signal an event before the timeoutIndicator MaybeSource signals, a TimeoutException is signalled instead.
final Maybe<T> timeout(long timeout, TimeUnit timeUnit, Scheduler scheduler, MaybeSource<? extends T> fallback)
Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item using a specified Scheduler.
final <U> Maybe<T> timeout(Publisher<U> timeoutIndicator)
If this Maybe source didn't signal an event before the timeoutIndicator Publisher signals, a TimeoutException is signalled instead.
final Maybe<T> timeout(long timeout, TimeUnit timeUnit, Scheduler scheduler)
Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item, where this policy is governed on a specified Scheduler.
static Maybe<Long> timer(long delay, TimeUnit unit, Scheduler scheduler)
Returns a Maybe that emits 0L after a specified delay on a specified Scheduler.
static Maybe<Long> timer(long delay, TimeUnit unit)
Returns a Maybe that emits 0L after a specified delay.
final <R> R to(Function<? super Maybe<T>, R> convert)
Calls the specified converter function with the current Maybe instance during assembly time and returns its result.
final Flowable<T> toFlowable()
Converts this Maybe into a backpressure-aware Flowable instance composing cancellation through.
final Observable<T> toObservable()
Converts this Maybe into an Observable instance composing cancellation through.
final Single<T> toSingle()
Converts this Maybe into a Single instance composing cancellation through and turning an empty Maybe into a signal of NoSuchElementException.
final Single<T> toSingle(T defaultValue)
Converts this Maybe into a Single instance composing cancellation through and turning an empty Maybe into a Single that emits the given value through onSuccess.
static <T> Maybe<T> unsafeCreate(MaybeSource<T> onSubscribe)
Advanced use only: creates a Maybe instance without any safeguards by using a callback that is called with a MaybeObserver.
final Maybe<T> unsubscribeOn(Scheduler scheduler)
Returns a Maybe which makes sure when a MaybeObserver disposes the Disposable, that call is propagated up on the specified scheduler
Scheduler:
unsubscribeOn calls dispose() of the upstream on the Scheduler you specify.
static <T, D> Maybe<T> using(Callable<? extends D> resourceSupplier, Function<? super D, ? extends MaybeSource<? extends T>> sourceSupplier, Consumer<? super D> resourceDisposer)
Constructs a Maybe that creates a dependent resource object which is disposed of when the upstream terminates or the downstream calls dispose().
static <T, D> Maybe<T> using(Callable<? extends D> resourceSupplier, Function<? super D, ? extends MaybeSource<? extends T>> sourceSupplier, Consumer<? super D> resourceDisposer, boolean eager)
Constructs a Maybe that creates a dependent resource object which is disposed of just before termination if you have set disposeEagerly to true and a downstream dispose() does not occur before termination.
static <T> Maybe<T> wrap(MaybeSource<T> source)
Wraps a MaybeSource instance into a new Maybe instance if not already a Maybe instance.
static <T1, T2, T3, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, Function3<? super T1, ? super T2, ? super T3, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three other MaybeSources.
static <T, R> Maybe<R> zip(Iterable<? extends MaybeSource<? extends T>> sources, Function<? super Object[], ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other MaybeSources.
static <T1, T2, T3, T4, T5, T6, T7, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, Function7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven other MaybeSources.
static <T1, T2, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, BiFunction<? super T1, ? super T2, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other MaybeSources.
static <T1, T2, T3, T4, T5, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five other MaybeSources.
static <T1, T2, T3, T4, T5, T6, T7, T8, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, MaybeSource<? extends T8> source8, Function8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight other MaybeSources.
static <T1, T2, T3, T4, T5, T6, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, Function6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six other MaybeSources.
static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, MaybeSource<? extends T8> source8, MaybeSource<? extends T9> source9, Function9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine other MaybeSources.
static <T1, T2, T3, T4, R> Maybe<R> zip(MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipper)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four other MaybeSources.
static <T, R> Maybe<R> zipArray(Function<? super Object[], ? extends R> zipper, MaybeSource...<? extends T> sources)
Returns a Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of other MaybeSources.
final <U, R> Maybe<R> zipWith(MaybeSource<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper)
Waits until this and the other MaybeSource signal a success value then applies the given BiFunction to those values and emits the BiFunction's resulting value to downstream.
Protected Methods
abstract void subscribeActual(MaybeObserver<? super T> observer)
Override this method in subclasses to handle the incoming MaybeObservers.
[Expand]
Inherited Methods
From class java.lang.Object
From interface io.reactivex.MaybeSource

Public Constructors

public Maybe ()

Public Methods

public static Maybe<T> amb (Iterable<? extends MaybeSource<? extends T>> sources)

Runs multiple Maybe sources and signals the events of the first one that signals (cancelling the rest).

Scheduler:
amb does not operate by default on a particular Scheduler.

Parameters
sources the Iterable sequence of sources. A subscription to each source will occur in the same order as in the Iterable.
Returns
  • the new Maybe instance

public static Maybe<T> ambArray (MaybeSource...<? extends T> sources)

Runs multiple Maybe sources and signals the events of the first one that signals (cancelling the rest).

Scheduler:
ambArray does not operate by default on a particular Scheduler.

Parameters
sources the array of sources. A subscription to each source will occur in the same order as in the array.
Returns
  • the new Maybe instance

public final Maybe<T> ambWith (MaybeSource<? extends T> other)

Mirrors the MaybeSource (current or provided) that first signals an event.

Scheduler:
ambWith does not operate by default on a particular Scheduler.

Parameters
other a MaybeSource competing to react first. A subscription to this provided source will occur after subscribing to the current source.
Returns
  • a Maybe that emits the same sequence as whichever of the source MaybeSources first signalled

public final T blockingGet (T defaultValue)

Waits in a blocking fashion until the current Maybe signals a success value (which is returned), defaultValue if completed or an exception (which is propagated).

Scheduler:
blockingGet does not operate by default on a particular Scheduler.

Parameters
defaultValue the default item to return if this Maybe is empty
Returns
  • the success value

public final T blockingGet ()

Waits in a blocking fashion until the current Maybe signals a success value (which is returned), null if completed or an exception (which is propagated).

Scheduler:
blockingGet does not operate by default on a particular Scheduler.

Returns
  • the success value

public final Maybe<T> cache ()

Returns a Maybe that subscribes to this Maybe lazily, caches its event and replays it, to all the downstream subscribers.

The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this Maybe.

Note: You sacrifice the ability to dispose the origin when you use the cache.

Scheduler:
cache does not operate by default on a particular Scheduler.

Returns
  • a Maybe that, when first subscribed to, caches all of its items and notifications for the benefit of subsequent subscribers

public final Maybe<U> cast (Class<? extends U> clazz)

Casts the success value of the current Maybe into the target type or signals a ClassCastException if not compatible.

Scheduler:
cast does not operate by default on a particular Scheduler.

Parameters
clazz the type token to use for casting the success result from the current Maybe
Returns
  • the new Maybe instance

public final Maybe<R> compose (MaybeTransformer<? super T, ? extends R> transformer)

Transform a Maybe by applying a particular Transformer function to it.

This method operates on the Maybe itself whereas lift(MaybeOperator) operates on the Maybe's MaybeObservers.

If the operator you are creating is designed to act on the individual item emitted by a Maybe, use lift(MaybeOperator). If your operator is designed to transform the source Maybe as a whole (for instance, by applying a particular set of existing RxJava operators to it) use compose.

Scheduler:
compose does not operate by default on a particular Scheduler.

Parameters
transformer the transformer function, not null
Returns
  • a Maybe, transformed by the transformer function

public static Flowable<T> concat (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)

Returns a Flowable that emits the items emitted by two MaybeSources, one after the other.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be concatenated
source2 a MaybeSource to be concatenated
Returns
  • a Flowable that emits items emitted by the two source MaybeSources, one after the other.

public static Flowable<T> concat (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)

Returns a Flowable that emits the items emitted by three MaybeSources, one after the other.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be concatenated
source2 a MaybeSource to be concatenated
source3 a MaybeSource to be concatenated
Returns
  • a Flowable that emits items emitted by the three source MaybeSources, one after the other.

public static Flowable<T> concat (Iterable<? extends MaybeSource<? extends T>> sources)

Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by an Iterable sequence.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
sources the Iterable sequence of MaybeSource instances
Returns
  • the new Flowable instance

public static Flowable<T> concat (Publisher<? extends MaybeSource<? extends T>> sources)

Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by a Publisher sequence.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer and expects the Publisher to honor backpressure as well. If the sources Publisher violates this, a MissingBackpressureException is signalled.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
sources the Publisher of MaybeSource instances
Returns
  • the new Flowable instance

public static Flowable<T> concat (Publisher<? extends MaybeSource<? extends T>> sources, int prefetch)

Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by a Publisher sequence.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer and expects the Publisher to honor backpressure as well. If the sources Publisher violates this, a MissingBackpressureException is signalled.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
sources the Publisher of MaybeSource instances
prefetch the number of MaybeSources to prefetch from the Publisher
Returns
  • the new Flowable instance

public static Flowable<T> concat (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)

Returns a Flowable that emits the items emitted by four MaybeSources, one after the other.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer.
Scheduler:
concat does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be concatenated
source2 a MaybeSource to be concatenated
source3 a MaybeSource to be concatenated
source4 a MaybeSource to be concatenated
Returns
  • a Flowable that emits items emitted by the four source MaybeSources, one after the other.

public static Flowable<T> concatArray (MaybeSource...<? extends T> sources)

Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources in the array.

Backpressure:
The returned Flowable honors the backpressure of the downstream consumer.
Scheduler:
concatArray does not operate by default on a particular Scheduler.

Parameters
sources the array of MaybeSource instances
Returns
  • the new Flowable instance

public static Flowable<T> concatArrayDelayError (MaybeSource...<? extends T> sources)

Concatenates a variable number of MaybeSource sources and delays errors from any of them till all terminate.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
concatArrayDelayError does not operate by default on a particular Scheduler.

Parameters
sources the array of sources
Returns
  • the new Flowable instance
Throws
NullPointerException if sources is null

public static Flowable<T> concatArrayEager (MaybeSource...<? extends T> sources)

Concatenates a sequence of MaybeSource eagerly into a single stream of values.

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source MaybeSources. The operator buffers the value emitted by these MaybeSources and then drains them in order, each one after the previous one completes.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
This method does not operate by default on a particular Scheduler.

Parameters
sources a sequence of MaybeSources that need to be eagerly concatenated
Returns
  • the new Flowable instance with the specified concatenation behavior

public static Flowable<T> concatDelayError (Publisher<? extends MaybeSource<? extends T>> sources)

Concatenates the Publisher sequence of Publishers into a single sequence by subscribing to each inner Publisher, one after the other, one at a time and delays any errors till the all inner and the outer Publishers terminate.

Backpressure:
concatDelayError fully supports backpressure.
Scheduler:
concatDelayError does not operate by default on a particular Scheduler.

Parameters
sources the Publisher sequence of Publishers
Returns
  • the new Publisher with the concatenating behavior

public static Flowable<T> concatDelayError (Iterable<? extends MaybeSource<? extends T>> sources)

Concatenates the Iterable sequence of MaybeSources into a single sequence by subscribing to each MaybeSource, one after the other, one at a time and delays any errors till the all inner MaybeSources terminate.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
concatDelayError does not operate by default on a particular Scheduler.

Parameters
sources the Iterable sequence of MaybeSources
Returns
  • the new Flowable with the concatenating behavior

public static Flowable<T> concatEager (Iterable<? extends MaybeSource<? extends T>> sources)

Concatenates a sequence of MaybeSources eagerly into a single stream of values.

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source MaybeSources. The operator buffers the values emitted by these MaybeSources and then drains them in order, each one after the previous one completes.

Backpressure:
Backpressure is honored towards the downstream.
Scheduler:
This method does not operate by default on a particular Scheduler.

Parameters
sources a sequence of MaybeSource that need to be eagerly concatenated
Returns
  • the new Flowable instance with the specified concatenation behavior

public static Flowable<T> concatEager (Publisher<? extends MaybeSource<? extends T>> sources)

Concatenates a Publisher sequence of Publishers eagerly into a single stream of values.

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Publishers as they are observed. The operator buffers the values emitted by these Publishers and then drains them in order, each one after the previous one completes.

Backpressure:
Backpressure is honored towards the downstream and the outer Publisher is expected to support backpressure. Violating this assumption, the operator will signal MissingBackpressureException.
Scheduler:
This method does not operate by default on a particular Scheduler.

Parameters
sources a sequence of Publishers that need to be eagerly concatenated
Returns
  • the new Publisher instance with the specified concatenation behavior

public final Maybe<R> concatMap (Function<? super T, ? extends MaybeSource<? extends R>> mapper)

Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe, where that function returns a MaybeSource.

Scheduler:
concatMap does not operate by default on a particular Scheduler.

Note that flatMap and concatMap for Maybe is the same operation.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns a MaybeSource
Returns
  • the Maybe returned from func when applied to the item emitted by the source Maybe

public final Flowable<T> concatWith (MaybeSource<? extends T> other)

Returns a Flowable that emits the items emitted from the current MaybeSource, then the next, one after the other, without interleaving them.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
concatWith does not operate by default on a particular Scheduler.

Parameters
other a MaybeSource to be concatenated after the current
Returns
  • a Flowable that emits items emitted by the two source MaybeSources, one after the other, without interleaving them

public final Single<Boolean> contains (Object item)

Returns a Single that emits a Boolean that indicates whether the source Maybe emitted a specified item.

Scheduler:
contains does not operate by default on a particular Scheduler.

Parameters
item the item to search for in the emissions from the source Maybe, not null
Returns
  • a Single that emits true if the specified item is emitted by the source Maybe, or false if the source Maybe completes without emitting that item

public final Single<Long> count ()

Returns a Maybe that counts the total number of items emitted (0 or 1) by the source Maybe and emits this count as a 64-bit Long.

Scheduler:
count does not operate by default on a particular Scheduler.

Returns
  • a Single that emits a single item: the number of items emitted by the source Maybe as a 64-bit Long item

public static Maybe<T> create (MaybeOnSubscribe<T> onSubscribe)

Provides an API (via a cold Maybe) that bridges the reactive world with the callback-style world.

Example:


 Maybe.<Event>create(emitter -> {
     Callback listener = new Callback() {
         @Override
         public void onEvent(Event e) {
             if (e.isNothing()) {
                 emitter.onComplete();
             } else {
                 emitter.onSuccess(e);
             }
         }

         @Override
         public void onFailure(Exception e) {
             emitter.onError(e);
         }
     };

     AutoCloseable c = api.someMethod(listener);

     emitter.setCancellable(c::close);

 });
 

Scheduler:
create does not operate by default on a particular Scheduler.

Parameters
onSubscribe the emitter that is called when a MaybeObserver subscribes to the returned Maybe
Returns
  • the new Maybe instance

public final Maybe<T> defaultIfEmpty (T defaultItem)

Returns a Maybe that emits the item emitted by the source Maybe or a specified default item if the source Maybe is empty.

Note that the result Maybe is semantically equivalent to a Single, since it's guaranteed to emit exactly one item or an error. See toSingle(Object) for a method with equivalent behavior which returns a Single.

Scheduler:
defaultIfEmpty does not operate by default on a particular Scheduler.

Parameters
defaultItem the item to emit if the source Maybe emits no items
Returns
  • a Maybe that emits either the specified default item if the source Maybe emits no items, or the items emitted by the source Maybe

public static Maybe<T> defer (Callable<? extends MaybeSource<? extends T>> maybeSupplier)

Calls a Callable for each individual MaybeObserver to return the actual MaybeSource source to be subscribed to.

Scheduler:
defer does not operate by default on a particular Scheduler.

Parameters
maybeSupplier the Callable that is called for each individual MaybeObserver and returns a MaybeSource instance to subscribe to
Returns
  • the new Maybe instance

public final Maybe<T> delay (Publisher<U> delayIndicator)

Delays the emission of this Maybe until the given Publisher signals an item or completes.

Backpressure:
The delayIndicator is consumed in an unbounded manner but is cancelled after the first item it produces.
Scheduler:
This version of delay does not operate by default on a particular Scheduler.

Parameters
delayIndicator the Publisher that gets subscribed to when this Maybe signals an event and that signal is emitted when the Publisher signals an item or completes
Returns
  • the new Maybe instance

public final Maybe<T> delay (long delay, TimeUnit unit)

Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a specified delay.

Scheduler:
This version of delay operates by default on the computation Scheduler.

Parameters
delay the delay to shift the source by
unit the TimeUnit in which period is defined
Returns
  • the new Maybe instance

public final Maybe<T> delay (long delay, TimeUnit unit, Scheduler scheduler)

Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a specified delay running on the specified Scheduler.

Scheduler:
you specify which Scheduler this operator will use

Parameters
delay the delay to shift the source by
unit the time unit of delay
scheduler the Scheduler to use for delaying
Returns
  • the new Maybe instance

public final Maybe<T> delaySubscription (Publisher<U> subscriptionIndicator)

Returns a Maybe that delays the subscription to this Maybe until the other Publisher emits an element or completes normally.

Backpressure:
The Publisher source is consumed in an unbounded fashion (without applying backpressure).
Scheduler:
This method does not operate by default on a particular Scheduler.

Parameters
subscriptionIndicator the other Publisher that should trigger the subscription to this Publisher.
Returns
  • a Maybe that delays the subscription to this Maybe until the other Publisher emits an element or completes normally.

public final Maybe<T> delaySubscription (long delay, TimeUnit unit, Scheduler scheduler)

Returns a Maybe that delays the subscription to the source Maybe by a given amount of time, both waiting and subscribing on a given Scheduler.

Scheduler:
You specify which Scheduler this operator will use

Parameters
delay the time to delay the subscription
unit the time unit of delay
scheduler the Scheduler on which the waiting and subscription will happen
Returns
  • a Maybe that delays the subscription to the source Maybe by a given amount, waiting and subscribing on the given Scheduler

public final Maybe<T> delaySubscription (long delay, TimeUnit unit)

Returns a Maybe that delays the subscription to the source Maybe by a given amount of time.

Scheduler:
This version of delaySubscription operates by default on the computation Scheduler.

Parameters
delay the time to delay the subscription
unit the time unit of delay
Returns
  • a Maybe that delays the subscription to the source Maybe by the given amount

public final Maybe<T> doAfterSuccess (Consumer<? super T> onAfterSuccess)

Calls the specified consumer with the success item after this item has been emitted to the downstream.

Note that the onAfterNext action is shared between subscriptions and as such should be thread-safe.

Scheduler:
doAfterSuccess does not operate by default on a particular Scheduler.

History: 2.0.1 - experimental

Parameters
onAfterSuccess the Consumer that will be called after emitting an item from upstream to the downstream
Returns
  • the new Maybe instance

public final Maybe<T> doAfterTerminate (Action onAfterTerminate)

Registers an Action to be called when this Maybe invokes either onSuccess, onComplete or onError.

Scheduler:
doAfterTerminate does not operate by default on a particular Scheduler.

Parameters
onAfterTerminate an Action to be invoked when the source Maybe finishes
Returns
  • a Maybe that emits the same items as the source Maybe, then invokes the Action

public final Maybe<T> doFinally (Action onFinally)

Calls the specified action after this Maybe signals onSuccess, onError or onComplete or gets disposed by the downstream.

In case of a race between a terminal event and a dispose call, the provided onFinally action is executed once per subscription.

Note that the onFinally action is shared between subscriptions and as such should be thread-safe.

Scheduler:
doFinally does not operate by default on a particular Scheduler.

History: 2.0.1 - experimental

Parameters
onFinally the action called when this Maybe terminates or gets cancelled
Returns
  • the new Maybe instance

public final Maybe<T> doOnComplete (Action onComplete)

Modifies the source Maybe so that it invokes an action when it calls onComplete.

Scheduler:
doOnComplete does not operate by default on a particular Scheduler.

Parameters
onComplete the action to invoke when the source Maybe calls onComplete
Returns
  • the new Maybe with the side-effecting behavior applied

public final Maybe<T> doOnDispose (Action onDispose)

Calls the shared Action if a MaybeObserver subscribed to the current Maybe disposes the common Disposable it received via onSubscribe.

Scheduler:
doOnDispose does not operate by default on a particular Scheduler.

Parameters
onDispose the action called when the subscription is cancelled (disposed)
Returns
  • the new Maybe instance
Throws
NullPointerException if onDispose is null

public final Maybe<T> doOnError (Consumer<? super Throwable> onError)

Calls the shared consumer with the error sent via onError for each MaybeObserver that subscribes to the current Maybe.

Scheduler:
doOnError does not operate by default on a particular Scheduler.

Parameters
onError the consumer called with the success value of onError
Returns
  • the new Maybe instance

public final Maybe<T> doOnEvent (BiConsumer<? super T, ? super Throwable> onEvent)

Calls the given onEvent callback with the (success value, null) for an onSuccess, (null, throwable) for an onError or (null, null) for an onComplete signal from this Maybe before delivering said signal to the downstream.

Exceptions thrown from the callback will override the event so the downstream receives the error instead of the original signal.

Scheduler:
doOnEvent does not operate by default on a particular Scheduler.

Parameters
onEvent the callback to call with the terminal event tuple
Returns
  • the new Maybe instance

public final Maybe<T> doOnSubscribe (Consumer<? super Disposable> onSubscribe)

Calls the shared consumer with the Disposable sent through the onSubscribe for each MaybeObserver that subscribes to the current Maybe.

Scheduler:
doOnSubscribe does not operate by default on a particular Scheduler.

Parameters
onSubscribe the consumer called with the Disposable sent via onSubscribe
Returns
  • the new Maybe instance

public final Maybe<T> doOnSuccess (Consumer<? super T> onSuccess)

Calls the shared consumer with the success value sent via onSuccess for each MaybeObserver that subscribes to the current Maybe.

Scheduler:
doOnSuccess does not operate by default on a particular Scheduler.

Parameters
onSuccess the consumer called with the success value of onSuccess
Returns
  • the new Maybe instance

public static Maybe<T> empty ()

Returns a (singleton) Maybe instance that calls onComplete immediately.

Scheduler:
empty does not operate by default on a particular Scheduler.

Returns
  • the new Maybe instance

public static Maybe<T> error (Throwable exception)

Returns a Maybe that invokes a subscriber's onError method when the subscriber subscribes to it.

Scheduler:
error does not operate by default on a particular Scheduler.

Parameters
exception the particular Throwable to pass to onError
Returns
  • a Maybe that invokes the subscriber's onError method when the subscriber subscribes to it

public static Maybe<T> error (Callable<? extends Throwable> supplier)

Returns a Maybe that invokes a MaybeObserver's onError method when the MaybeObserver subscribes to it.

Scheduler:
error does not operate by default on a particular Scheduler.

Parameters
supplier a Callable factory to return a Throwable for each individual MaybeObserver
Returns

public final Maybe<T> filter (Predicate<? super T> predicate)

Filters the success item of the Maybe via a predicate function and emitting it if the predicate returns true, completing otherwise.

Scheduler:
filter does not operate by default on a particular Scheduler.

Parameters
predicate a function that evaluates the item emitted by the source Maybe, returning true if it passes the filter
Returns
  • a Maybe that emit the item emitted by the source Maybe that the filter evaluates as true

public final Maybe<R> flatMap (Function<? super T, ? extends MaybeSource<? extends U>> mapper, BiFunction<? super T, ? super U, ? extends R> resultSelector)

Returns a Maybe that emits the results of a specified function to the pair of values emitted by the source Maybe and a specified mapped MaybeSource.

Scheduler:
flatMap does not operate by default on a particular Scheduler.

Parameters
mapper a function that returns a MaybeSource for the item emitted by the source Maybe
resultSelector a function that combines one item emitted by each of the source and collection MaybeSource and returns an item to be emitted by the resulting MaybeSource
Returns
  • the new Maybe instance

public final Maybe<R> flatMap (Function<? super T, ? extends MaybeSource<? extends R>> onSuccessMapper, Function<? super Throwable, ? extends MaybeSource<? extends R>> onErrorMapper, Callable<? extends MaybeSource<? extends R>> onCompleteSupplier)

Maps the onSuccess, onError or onComplete signals of this Maybe into MaybeSource and emits that MaybeSource's signals

Scheduler:
flatMap does not operate by default on a particular Scheduler.

Parameters
onSuccessMapper a function that returns a MaybeSource to merge for the onSuccess item emitted by this Maybe
onErrorMapper a function that returns a MaybeSource to merge for an onError notification from this Maybe
onCompleteSupplier a function that returns a MaybeSource to merge for an onComplete notification this Maybe
Returns
  • the new Maybe instance

public final Maybe<R> flatMap (Function<? super T, ? extends MaybeSource<? extends R>> mapper)

Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe, where that function returns a MaybeSource.

Scheduler:
flatMap does not operate by default on a particular Scheduler.

Note that flatMap and concatMap for Maybe is the same operation.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns a MaybeSource
Returns
  • the Maybe returned from func when applied to the item emitted by the source Maybe

public final Completable flatMapCompletable (Function<? super T, ? extends CompletableSource> mapper)

Returns a Completable that completes based on applying a specified function to the item emitted by the source Maybe, where that function returns a Completable.

Scheduler:
flatMapCompletable does not operate by default on a particular Scheduler.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns a Completable
Returns
  • the Completable returned from mapper when applied to the item emitted by the source Maybe

public final Observable<R> flatMapObservable (Function<? super T, ? extends ObservableSource<? extends R>> mapper)

Returns an Observable that is based on applying a specified function to the item emitted by the source Maybe, where that function returns an ObservableSource.

Scheduler:
flatMapObservable does not operate by default on a particular Scheduler.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns an ObservableSource
Returns
  • the Observable returned from func when applied to the item emitted by the source Maybe

public final Flowable<R> flatMapPublisher (Function<? super T, ? extends Publisher<? extends R>> mapper)

Returns a Flowable that emits items based on applying a specified function to the item emitted by the source Maybe, where that function returns a Publisher.

Backpressure:
The returned Flowable honors the downstream backpressure.
Scheduler:
flatMapPublisher does not operate by default on a particular Scheduler.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns an Flowable
Returns
  • the Flowable returned from func when applied to the item emitted by the source Maybe

public final Single<R> flatMapSingle (Function<? super T, ? extends SingleSource<? extends R>> mapper)

Returns a Single based on applying a specified function to the item emitted by the source Maybe, where that function returns a Single. When this Maybe completes a NoSuchElementException will be thrown.

Scheduler:
flatMapSingle does not operate by default on a particular Scheduler.

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns a Single
Returns
  • the Single returned from mapper when applied to the item emitted by the source Maybe

public final Maybe<R> flatMapSingleElement (Function<? super T, ? extends SingleSource<? extends R>> mapper)

Returns a Maybe based on applying a specified function to the item emitted by the source Maybe, where that function returns a Single. When this Maybe just completes the resulting Maybe completes as well.

Scheduler:
flatMapSingleElement does not operate by default on a particular Scheduler.

History: 2.0.2 - experimental

Parameters
mapper a function that, when applied to the item emitted by the source Maybe, returns a Single
Returns
  • the new Maybe instance

public final Flowable<U> flattenAsFlowable (Function<? super T, ? extends Iterable<? extends U>> mapper)

Returns a Flowable that merges each item emitted by the source Maybe with the values in an Iterable corresponding to that item that is generated by a selector.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
flattenAsFlowable does not operate by default on a particular Scheduler.

Parameters
mapper a function that returns an Iterable sequence of values for when given an item emitted by the source Maybe
Returns
  • the new Flowable instance

public final Observable<U> flattenAsObservable (Function<? super T, ? extends Iterable<? extends U>> mapper)

Returns an Observable that maps a success value into an Iterable and emits its items.

Scheduler:
flattenAsObservable does not operate by default on a particular Scheduler.

Parameters
mapper a function that returns an Iterable sequence of values for when given an item emitted by the source Maybe
Returns
  • the new Observable instance

public static Maybe<T> fromAction (Action run)

Returns a Maybe instance that runs the given Action for each subscriber and emits either its exception or simply completes.

Scheduler:
fromAction does not operate by default on a particular Scheduler.

Parameters
run the runnable to run for each subscriber
Returns
  • the new Maybe instance
Throws
NullPointerException if run is null

public static Maybe<T> fromCallable (Callable<? extends T> callable)

Returns a Maybe that invokes passed function and emits its result for each new MaybeObserver that subscribes while considering null value from the callable as indication for valueless completion.

Allows you to defer execution of passed function until MaybeObserver subscribes to the Maybe. It makes passed function "lazy". Result of the function invocation will be emitted by the Maybe.

Scheduler:
fromCallable does not operate by default on a particular Scheduler.

Parameters
callable function which execution should be deferred, it will be invoked when MaybeObserver will subscribe to the Maybe.
Returns

public static Maybe<T> fromCompletable (CompletableSource completableSource)

Wraps a CompletableSource into a Maybe.

Scheduler:
fromCompletable does not operate by default on a particular Scheduler.

Parameters
completableSource the CompletableSource to convert from
Returns
  • the new Maybe instance
Throws
NullPointerException if completable is null

public static Maybe<T> fromFuture (Future<? extends T> future)

Converts a Future into a Maybe, treating a null result as an indication of emptiness.

You can convert any object that supports the Future interface into a Maybe that emits the return value of the get() method of that object, by passing the object into the from method.

Important note: This Maybe is blocking; you cannot dispose it.

Unlike 1.x, cancelling the Maybe won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futureMaybe.doOnDispose(() -> future.cancel(true));.

Scheduler:
fromFuture does not operate by default on a particular Scheduler.

Parameters
future the source Future
Returns
  • a Maybe that emits the item from the source Future

public static Maybe<T> fromFuture (Future<? extends T> future, long timeout, TimeUnit unit)

Converts a Future into a Maybe, with a timeout on the Future.

You can convert any object that supports the Future interface into a Maybe that emits the return value of the get() method of that object, by passing the object into the fromFuture method.

Unlike 1.x, cancelling the Maybe won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futureMaybe.doOnCancel(() -> future.cancel(true));.

Important note: This Maybe is blocking on the thread it gets subscribed on; you cannot dispose it.

Scheduler:
fromFuture does not operate by default on a particular Scheduler.

Parameters
future the source Future
timeout the maximum time to wait before calling get
unit the TimeUnit of the timeout argument
Returns
  • a Maybe that emits the item from the source Future

public static Maybe<T> fromRunnable (Runnable run)

Returns a Maybe instance that runs the given Action for each subscriber and emits either its exception or simply completes.

Scheduler:
fromRunnable does not operate by default on a particular Scheduler.

Parameters
run the runnable to run for each subscriber
Returns
  • the new Maybe instance
Throws
NullPointerException if run is null

public static Maybe<T> fromSingle (SingleSource<T> singleSource)

Wraps a SingleSource into a Maybe.

Scheduler:
fromSingle does not operate by default on a particular Scheduler.

Parameters
singleSource the SingleSource to convert from
Returns
  • the new Maybe instance
Throws
NullPointerException if single is null

public final Maybe<T> hide ()

Hides the identity of this Maybe and its Disposable.

Allows preventing certain identity-based optimizations (fusion).

Scheduler:
hide does not operate by default on a particular Scheduler.

Returns
  • the new Maybe instance

public final Completable ignoreElement ()

Ignores the item emitted by the source Maybe and only calls onComplete or onError.

Scheduler:
ignoreElement does not operate by default on a particular Scheduler.

Returns
  • an empty Completable that only calls onComplete or onError, based on which one is called by the source Maybe

public final Single<Boolean> isEmpty ()

Returns a Single that emits true if the source Maybe is empty, otherwise false.

Scheduler:
isEmpty does not operate by default on a particular Scheduler.

Returns
  • a Single that emits a Boolean

public static Maybe<T> just (T item)

Returns a Maybe that emits a specified item.

To convert any object into a Maybe that emits that object, pass that object into the just method.

Scheduler:
just does not operate by default on a particular Scheduler.

Parameters
item the item to emit
Returns
  • a Maybe that emits item

public final Maybe<R> lift (MaybeOperator<? extends R, ? super T> lift)

Lifts a function to the current Maybe and returns a new Maybe that when subscribed to will pass the values of the current Maybe through the MaybeOperator function.

In other words, this allows chaining TaskExecutors together on a Maybe for acting on the values within the Maybe.

task.map(...).filter(...).lift(new OperatorA()).lift(new OperatorB(...)).subscribe()

If the operator you are creating is designed to act on the item emitted by a source Maybe, use lift. If your operator is designed to transform the source Maybe as a whole (for instance, by applying a particular set of existing RxJava operators to it) use compose(MaybeTransformer).

Scheduler:
lift does not operate by default on a particular Scheduler.

Parameters
lift the MaybeOperator that implements the Maybe-operating function to be applied to the source Maybe
Returns
  • a Maybe that is the result of applying the lifted Operator to the source Maybe

public final Maybe<R> map (Function<? super T, ? extends R> mapper)

Returns a Maybe that applies a specified function to the item emitted by the source Maybe and emits the result of this function application.

Scheduler:
map does not operate by default on a particular Scheduler.

Parameters
mapper a function to apply to the item emitted by the Maybe
Returns
  • a Maybe that emits the item from the source Maybe, transformed by the specified function

public static Maybe<T> merge (MaybeSource<? extends MaybeSource<? extends T>> source)

Flattens a MaybeSource that emits a MaybeSource into a single MaybeSource that emits the item emitted by the nested MaybeSource, without any transformation.

Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
source a MaybeSource that emits a MaybeSource
Returns
  • a Maybe that emits the item that is the result of flattening the MaybeSource emitted by source

public static Flowable<T> merge (Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)

Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence, running at most maxConcurrency MaybeSources at once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
sources the Flowable sequence of MaybeSource sources
maxConcurrency the maximum number of concurrently running MaybeSources
Returns
  • the new Flowable instance

public static Flowable<T> merge (Publisher<? extends MaybeSource<? extends T>> sources)

Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
sources the Flowable sequence of MaybeSource sources
Returns
  • the new Flowable instance

public static Flowable<T> merge (Iterable<? extends MaybeSource<? extends T>> sources)

Merges an Iterable sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
sources the Iterable sequence of MaybeSource sources
Returns
  • the new Flowable instance

public static Flowable<T> merge (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)

Flattens two MaybeSources into a single Flowable, without any transformation.

You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by using the merge method.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items emitted by the source MaybeSources

public static Flowable<T> merge (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)

Flattens four MaybeSources into a single Flowable, without any transformation.

You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by using the merge method.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
source3 a MaybeSource to be merged
source4 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items emitted by the source MaybeSources

public static Flowable<T> merge (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)

Flattens three MaybeSources into a single Flowable, without any transformation.

You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by using the merge method.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
merge does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
source3 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items emitted by the source MaybeSources

public static Flowable<T> mergeArray (MaybeSource...<? extends T> sources)

Merges an array sequence of MaybeSource instances into a single Flowable sequence, running all MaybeSources at once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeArray does not operate by default on a particular Scheduler.

Parameters
sources the array sequence of MaybeSource sources
Returns
  • the new Flowable instance

public static Flowable<T> mergeArrayDelayError (MaybeSource...<? extends T> sources)

Flattens an array of MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.

This behaves like merge(Publisher) except that if any of the merged MaybeSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged MaybeSources have finished emitting items.

Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeArrayDelayError does not operate by default on a particular Scheduler.

Parameters
sources the Iterable of MaybeSources
Returns
  • a Flowable that emits items that are the result of flattening the items emitted by the MaybeSources in the Iterable

public static Flowable<T> mergeDelayError (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)

Flattens three MaybeSource into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from all of the source MaybeSources without being interrupted by an error notification from one of them.

This behaves like merge(MaybeSource, MaybeSource, MaybeSource) except that if any of the merged MaybeSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged MaybeSources have finished emitting items.

Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeDelayError does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
source3 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items that are emitted by the source MaybeSources

public static Flowable<T> mergeDelayError (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)

Flattens four MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from all of the source MaybeSources without being interrupted by an error notification from one of them.

This behaves like merge(MaybeSource, MaybeSource, MaybeSource, MaybeSource) except that if any of the merged MaybeSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged MaybeSources have finished emitting items.

Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeDelayError does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
source3 a MaybeSource to be merged
source4 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items that are emitted by the source MaybeSources

public static Flowable<T> mergeDelayError (Iterable<? extends MaybeSource<? extends T>> sources)

Flattens an Iterable of MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.

This behaves like merge(Publisher) except that if any of the merged MaybeSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged MaybeSources have finished emitting items.

Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeDelayError does not operate by default on a particular Scheduler.

Parameters
sources the Iterable of MaybeSources
Returns
  • a Flowable that emits items that are the result of flattening the items emitted by the MaybeSources in the Iterable

public static Flowable<T> mergeDelayError (Publisher<? extends MaybeSource<? extends T>> sources)

Flattens a Publisher that emits MaybeSources into one Publisher, in a way that allows a Subscriber to receive all successfully emitted items from all of the source Publishers without being interrupted by an error notification from one of them.

This behaves like merge(Publisher) except that if any of the merged Publishers notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged Publishers have finished emitting items.

Even if multiple merged Publishers send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream. The outer Publisher is consumed in unbounded mode (i.e., no backpressure is applied to it).
Scheduler:
mergeDelayError does not operate by default on a particular Scheduler.

Parameters
sources a Publisher that emits MaybeSources
Returns
  • a Flowable that emits all of the items emitted by the Publishers emitted by the source Publisher

public static Flowable<T> mergeDelayError (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)

Flattens two MaybeSources into one Flowable, in a way that allows a Subscriber to receive all successfully emitted items from each of the source MaybeSources without being interrupted by an error notification from one of them.

This behaves like merge(MaybeSource, MaybeSource) except that if any of the merged MaybeSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged MaybeSources have finished emitting items.

Even if both merged MaybeSources send onError notifications, mergeDelayError will only invoke the onError method of its Subscribers once.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeDelayError does not operate by default on a particular Scheduler.

Parameters
source1 a MaybeSource to be merged
source2 a MaybeSource to be merged
Returns
  • a Flowable that emits all of the items that are emitted by the two source MaybeSources

public final Flowable<T> mergeWith (MaybeSource<? extends T> other)

Flattens this and another Maybe into a single Flowable, without any transformation.

You can combine items emitted by multiple Maybes so that they appear as a single Flowable, by using the mergeWith method.

Backpressure:
The operator honors backpressure from downstream.
Scheduler:
mergeWith does not operate by default on a particular Scheduler.

Parameters
other a MaybeSource to be merged
Returns
  • a new Flowable instance

public static Maybe<T> never ()

Returns a Maybe that never sends any items or notifications to a MaybeObserver.

This Maybe is useful primarily for testing purposes.

Scheduler:
never does not operate by default on a particular Scheduler.

Returns
  • a Maybe that never emits any items or sends any notifications to a MaybeObserver

public final Maybe<T> observeOn (Scheduler scheduler)

Wraps a Maybe to emit its item (or notify of its error) on a specified Scheduler, asynchronously.

Scheduler:
you specify which Scheduler this operator will use

Parameters
scheduler the Scheduler to notify subscribers on
Returns
  • the new Maybe instance that its subscribers are notified on the specified Scheduler

public final Maybe<U> ofType (Class<U> clazz)

Filters the items emitted by a Maybe, only emitting its success value if that is an instance of the supplied Class.

Scheduler:
ofType does not operate by default on a particular Scheduler.

Parameters
clazz the class type to filter the items emitted by the source Maybe
Returns
  • the new Maybe instance

public final Maybe<T> onErrorComplete (Predicate<? super Throwable> predicate)

Returns a Maybe instance that if this Maybe emits an error and the predicate returns true, it will emit an onComplete and swallow the throwable.

Scheduler:
onErrorComplete does not operate by default on a particular Scheduler.

Parameters
predicate the predicate to call when an Throwable is emitted which should return true if the Throwable should be swallowed and replaced with an onComplete.
Returns
  • the new Completable instance

public final Maybe<T> onErrorComplete ()

Returns a Maybe instance that if this Maybe emits an error, it will emit an onComplete and swallow the throwable.

Scheduler:
onErrorComplete does not operate by default on a particular Scheduler.

Returns
  • the new Completable instance

public final Maybe<T> onErrorResumeNext (Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction)

Instructs a Maybe to pass control to another Maybe rather than invoking onError if it encounters an error.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Scheduler:
onErrorResumeNext does not operate by default on a particular Scheduler.

Parameters
resumeFunction a function that returns a MaybeSource that will take over if the source Maybe encounters an error
Returns
  • the new Maybe instance

public final Maybe<T> onErrorResumeNext (MaybeSource<? extends T> next)

Instructs a Maybe to pass control to another MaybeSource rather than invoking onError if it encounters an error.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Scheduler:
onErrorResumeNext does not operate by default on a particular Scheduler.

Parameters
next the next Maybe source that will take over if the source Maybe encounters an error
Returns
  • the new Maybe instance

public final Maybe<T> onErrorReturn (Function<? super Throwable, ? extends T> valueSupplier)

Instructs a Maybe to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Scheduler:
onErrorReturn does not operate by default on a particular Scheduler.

Parameters
valueSupplier a function that returns a single value that will be emitted as success value the current Maybe signals an onError event
Returns
  • the new Maybe instance

public final Maybe<T> onErrorReturnItem (T item)

Instructs a Maybe to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Scheduler:
onErrorReturnItem does not operate by default on a particular Scheduler.

Parameters
item the value that is emitted as onSuccess in case this Maybe signals an onError
Returns
  • the new Maybe instance

public final Maybe<T> onExceptionResumeNext (MaybeSource<? extends T> next)

Instructs a Maybe to pass control to another MaybeSource rather than invoking onError if it encounters an Exception.

This differs from onErrorResumeNext(MaybeSource) in that this one does not handle Throwable or java.lang.Error but lets those continue through.

You can use this to prevent exceptions from propagating or to supply fallback data should exceptions be encountered.

Scheduler:
onExceptionResumeNext does not operate by default on a particular Scheduler.

Parameters
next the next MaybeSource that will take over if the source Maybe encounters an exception
Returns
  • the new Maybe instance

public final Maybe<T> onTerminateDetach ()

Nulls out references to the upstream producer and downstream MaybeObserver if the sequence is terminated or downstream calls dispose().

Scheduler:
onTerminateDetach does not operate by default on a particular Scheduler.

Returns
  • a Maybe which out references to the upstream producer and downstream MaybeObserver if the sequence is terminated or downstream calls dispose()

public final Flowable<T> repeat ()

Returns a Flowable that repeats the sequence of items emitted by the source Maybe indefinitely.

Backpressure:
The operator honors downstream backpressure.
Scheduler:
repeat does not operate by default on a particular Scheduler.

Returns
  • a Flowable that emits the items emitted by the source Maybe repeatedly and in sequence

public final Flowable<T> repeat (long times)

Returns a Flowable that repeats the sequence of items emitted by the source Maybe at most count times.

Backpressure:
This operator honors downstream backpressure.
Scheduler:
repeat does not operate by default on a particular Scheduler.

Parameters
times the number of times the source Maybe items are repeated, a count of 0 will yield an empty sequence
Returns
  • a Flowable that repeats the sequence of items emitted by the source Maybe at most count times
Throws
IllegalArgumentException if count is less than zero

public final Flowable<T> repeatUntil (BooleanSupplier stop)

Returns a Flowable that repeats the sequence of items emitted by the source Maybe until the provided stop function returns true.

Backpressure:
This operator honors downstream backpressure.
Scheduler:
repeatUntil does not operate by default on a particular Scheduler.

Parameters
stop a boolean supplier that is called when the current Flowable completes and unless it returns false, the current Flowable is resubscribed
Returns
  • the new Flowable instance
Throws
NullPointerException if stop is null

public final Flowable<T> repeatWhen (Function<? super Flowable<Object>, ? extends Publisher<?>> handler)

Returns a Flowable that emits the same values as the source Publisher with the exception of an onComplete. An onComplete notification from the source will result in the emission of a void item to the Publisher provided as an argument to the notificationHandler function. If that Publisher calls onComplete or onError then repeatWhen will call onComplete or onError on the child subscription. Otherwise, this Publisher will resubscribe to the source Publisher.

Backpressure:
The operator honors downstream backpressure and expects the source Publisher to honor backpressure as well. If this expectation is violated, the operator may throw an IllegalStateException.
Scheduler:
repeatWhen does not operate by default on a particular Scheduler.

Parameters
handler receives a Publisher of notifications with which a user can complete or error, aborting the repeat.
Returns
  • the source Publisher modified with repeat logic

public final Maybe<T> retry (long times, Predicate<? super Throwable> predicate)

Retries at most times or until the predicate returns false, whichever happens first.

Scheduler:
retry does not operate by default on a particular Scheduler.

Parameters
times the number of times to repeat
predicate the predicate called with the failure Throwable and should return true to trigger a retry.
Returns
  • the new Maybe instance

public final Maybe<T> retry (BiPredicate<? super Integer, ? super Throwable> predicate)

Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError and the predicate returns true for that specific exception and retry count.

Scheduler:
retry does not operate by default on a particular Scheduler.

Parameters
predicate the predicate that determines if a resubscription may happen in case of a specific exception and retry count
Returns
  • the nww Maybe instance

public final Maybe<T> retry (Predicate<? super Throwable> predicate)

Retries the current Maybe if it fails and the predicate returns true.

Scheduler:
retry does not operate by default on a particular Scheduler.

Parameters
predicate the predicate that receives the failure Throwable and should return true to trigger a retry.
Returns
  • the new Maybe instance

public final Maybe<T> retry ()

Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError (infinite retry count).

If the source Maybe calls onError(Throwable), this method will resubscribe to the source Maybe rather than propagating the onError call.

Scheduler:
retry does not operate by default on a particular Scheduler.

Returns
  • the nww Maybe instance

public final Maybe<T> retry (long count)

Returns a Maybe that mirrors the source Maybe, resubscribing to it if it calls onError up to a specified number of retries.

If the source Maybe calls onError(Throwable), this method will resubscribe to the source Maybe for a maximum of count resubscriptions rather than propagating the onError call.

Scheduler:
retry does not operate by default on a particular Scheduler.

Parameters
count number of retry attempts before failing
Returns
  • the new Maybe instance

public final Maybe<T> retryUntil (BooleanSupplier stop)

Retries until the given stop function returns true.

Scheduler:
retryUntil does not operate by default on a particular Scheduler.

Parameters
stop the function that should return true to stop retrying
Returns
  • the new Maybe instance

public final Maybe<T> retryWhen (Function<? super Flowable<Throwable>, ? extends Publisher<?>> handler)

Returns a Maybe that emits the same values as the source Maybe with the exception of an onError. An onError notification from the source will result in the emission of a Throwable item to the Publisher provided as an argument to the notificationHandler function. If that Publisher calls onComplete or onError then retry will call onComplete or onError on the child subscription. Otherwise, this Publisher will resubscribe to the source Publisher.

Example: This retries 3 times, each time incrementing the number of seconds it waits.


  Flowable.create((FlowableEmitter<? super String> s) -> {
      System.out.println("subscribing");
      s.onError(new RuntimeException("always fails"));
  }, BackpressureStrategy.BUFFER).retryWhen(attempts -> {
      return attempts.zipWith(Publisher.range(1, 3), (n, i) -> i).flatMap(i -> {
          System.out.println("delay retry by " + i + " second(s)");
          return Publisher.timer(i, TimeUnit.SECONDS);
      });
  }).blockingForEach(System.out::println);
 
Output is:
 subscribing
 delay retry by 1 second(s)
 subscribing
 delay retry by 2 second(s)
 subscribing
 delay retry by 3 second(s)
 subscribing
  
Scheduler:
retryWhen does not operate by default on a particular Scheduler.

Parameters
handler receives a Publisher of notifications with which a user can complete or error, aborting the retry
Returns
  • the new Maybe instance

public static Single<Boolean> sequenceEqual (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)

Returns a Single that emits a Boolean value that indicates whether two MaybeSource sequences are the same by comparing the items emitted by each MaybeSource pairwise.

Scheduler:
sequenceEqual does not operate by default on a particular Scheduler.

Parameters
source1 the first MaybeSource to compare
source2 the second MaybeSource to compare
Returns
  • a Single that emits a Boolean value that indicates whether the two sequences are the same

public static Single<Boolean> sequenceEqual (MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, BiPredicate<? super T, ? super T> isEqual)

Returns a Single that emits a Boolean value that indicates whether two MaybeSources are the same by comparing the items emitted by each MaybeSource pairwise based on the results of a specified equality function.

Scheduler:
sequenceEqual does not operate by default on a particular Scheduler.

Parameters
source1 the first MaybeSource to compare
source2 the second MaybeSource to compare
isEqual a function used to compare items emitted by each MaybeSource
Returns
  • a Single that emits a Boolean value that indicates whether the two MaybeSource sequences are the same according to the specified function

public final void subscribe (MaybeObserver<? super T> observer)

Subscribes the given MaybeObserver to this MaybeSource instance.

Parameters
observer the MaybeObserver, not null

public final Disposable subscribe (Consumer<? super T> onSuccess)

Subscribes to a Maybe and provides a callback to handle the items it emits.

If the Maybe emits an error, it is wrapped into an OnErrorNotImplementedException and routed to the RxJavaPlugins.onError handler.

Scheduler:
subscribe does not operate by default on a particular Scheduler.

Parameters
onSuccess the Consumer<T> you have designed to accept a success value from the Maybe
Returns
  • a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
Throws
NullPointerException if onSuccess is null

public final Disposable subscribe (Consumer<? super T> onSuccess, Consumer<? super Throwable> onError, Action onComplete)

Subscribes to a Maybe and provides callbacks to handle the items it emits and any error or completion notification it issues.

Scheduler:
subscribe does not operate by default on a particular Scheduler.

Parameters
onSuccess the Consumer<T> you have designed to accept a success value from the Maybe
onError the Consumer<Throwable> you have designed to accept any error notification from the Maybe
onComplete the Action you have designed to accept a completion notification from the Maybe
Returns
  • a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
Throws
NullPointerException if onSuccess is null, or if onError is null, or if onComplete is null

public final Disposable subscribe (Consumer<? super T> onSuccess, Consumer<? super Throwable> onError)

Subscribes to a Maybe and provides callbacks to handle the items it emits and any error notification it issues.

Scheduler:
subscribe does not operate by default on a particular Scheduler.

Parameters
onSuccess the Consumer<T> you have designed to accept a success value from the Maybe
onError the Consumer<Throwable> you have designed to accept any error notification from the Maybe
Returns
  • a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
Throws
NullPointerException if onSuccess is null, or if onError is null

public final Disposable subscribe ()

Subscribes to a Maybe and ignores onSuccess and onComplete emissions.

If the Maybe emits an error, it is wrapped into an OnErrorNotImplementedException and routed to the RxJavaPlugins.onError handler.

Scheduler:
subscribe does not operate by default on a particular Scheduler.

Returns
  • a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them

public final Maybe<T> subscribeOn (Scheduler scheduler)

Asynchronously subscribes subscribers to this Maybe on the specified Scheduler.

Scheduler:
you specify which Scheduler this operator will use

Parameters
scheduler the Scheduler to perform subscription actions on
Returns
  • the new Maybe instance that its subscriptions happen on the specified Scheduler

public final E subscribeWith (E observer)

Subscribes a given MaybeObserver (subclass) to this Maybe and returns the given MaybeObserver as is.

Usage example:


 Maybe<Integer> source = Maybe.just(1);
 CompositeDisposable composite = new CompositeDisposable();

 MaybeObserver<Integer> ms = new MaybeObserver<>() {
     // ...
 };

 composite.add(source.subscribeWith(ms));
 
Scheduler:
subscribeWith does not operate by default on a particular Scheduler.

Parameters
observer the MaybeObserver (subclass) to use and return, not null
Returns
  • the input subscriber
Throws
NullPointerException if subscriber is null

public final Maybe<T> switchIfEmpty (MaybeSource<? extends T> other)

Returns a Maybe that emits the items emitted by the source Maybe or the items of an alternate MaybeSource if the current Maybe is empty.

Scheduler:
switchIfEmpty does not operate by default on a particular Scheduler.

Parameters
other the alternate MaybeSource to subscribe to if the main does not emit any items
Returns
  • a Maybe that emits the items emitted by the source Maybe or the items of an alternate MaybeSource if the source Maybe is empty.

public final Maybe<T> takeUntil (Publisher<U> other)

Returns a Maybe that emits the item emitted by the source Maybe until a second Publisher emits an item.

Backpressure:
The Publisher is consumed in an unbounded fashion and is cancelled after the first item emitted.
Scheduler:
takeUntil does not operate by default on a particular Scheduler.

Parameters
other the Publisher whose first emitted item will cause takeUntil to stop emitting items from the source Publisher
Returns
  • a Maybe that emits the items emitted by the source Maybe until such time as other emits its first item

public final Maybe<T> takeUntil (MaybeSource<U> other)

Returns a Maybe that emits the items emitted by the source Maybe until a second MaybeSource emits an item.

Scheduler:
takeUntil does not operate by default on a particular Scheduler.

Parameters
other the MaybeSource whose first emitted item will cause takeUntil to stop emitting items from the source Maybe
Returns
  • a Maybe that emits the items emitted by the source Maybe until such time as other emits its first item

public final TestObserver<T> test (boolean cancelled)

Creates a TestObserver optionally in cancelled state, then subscribes it to this Maybe.

Scheduler:
test does not operate by default on a particular Scheduler.

Parameters
cancelled if true, the TestObserver will be cancelled before subscribing to this Maybe.
Returns
  • the new TestObserver instance

public final TestObserver<T> test ()

Creates a TestObserver and subscribes it to this Maybe.

Scheduler:
test does not operate by default on a particular Scheduler.

Returns
  • the new TestObserver instance

public final Maybe<T> timeout (long timeout, TimeUnit timeUnit)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Maybe terminates and notifies MaybeObservers of a TimeoutException.

Scheduler:
This version of timeout operates by default on the computation Scheduler.

Parameters
timeout maximum duration between emitted items before a timeout occurs
timeUnit the unit of time that applies to the timeout argument.
Returns
  • the new Maybe instance

public final Maybe<T> timeout (Publisher<U> timeoutIndicator, MaybeSource<? extends T> fallback)

If the current Maybe source didn't signal an event before the timeoutIndicator Publisher signals, the current Maybe is cancelled and the fallback MaybeSource subscribed to as a continuation.

Backpressure:
The timeoutIndicator Publisher is consumed in an unbounded manner and is cancelled after its first item.
Scheduler:
timeout does not operate by default on a particular Scheduler.

Parameters
timeoutIndicator the MaybeSource that indicates the timeout by signalling onSuccess or onComplete
fallback the MaybeSource that is subscribed to if the current Maybe times out
Returns
  • the new Maybe instance

public final Maybe<T> timeout (MaybeSource<U> timeoutIndicator, MaybeSource<? extends T> fallback)

If the current Maybe source didn't signal an event before the timeoutIndicator MaybeSource signals, the current Maybe is cancelled and the fallback MaybeSource subscribed to as a continuation.

Scheduler:
timeout does not operate by default on a particular Scheduler.

Parameters
timeoutIndicator the MaybeSource that indicates the timeout by signalling onSuccess or onComplete.
fallback the MaybeSource that is subscribed to if the current Maybe times out
Returns
  • the new Maybe instance

public final Maybe<T> timeout (long timeout, TimeUnit timeUnit, MaybeSource<? extends T> fallback)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Maybe begins instead to mirror a fallback MaybeSource.

Scheduler:
This version of timeout operates by default on the computation Scheduler.

Parameters
timeout maximum duration between items before a timeout occurs
timeUnit the unit of time that applies to the timeout argument
fallback the fallback MaybeSource to use in case of a timeout
Returns
  • the new Maybe instance

public final Maybe<T> timeout (MaybeSource<U> timeoutIndicator)

If this Maybe source didn't signal an event before the timeoutIndicator MaybeSource signals, a TimeoutException is signalled instead.

Scheduler:
timeout does not operate by default on a particular Scheduler.

Parameters
timeoutIndicator the MaybeSource that indicates the timeout by signalling onSuccess or onComplete.
Returns
  • the new Maybe instance

public final Maybe<T> timeout (long timeout, TimeUnit timeUnit, Scheduler scheduler, MaybeSource<? extends T> fallback)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item using a specified Scheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Maybe begins instead to mirror a fallback MaybeSource.

Scheduler:
You specify which Scheduler this operator will use

Parameters
timeout maximum duration between items before a timeout occurs
timeUnit the unit of time that applies to the timeout argument
scheduler the Scheduler to run the timeout timers on
fallback the MaybeSource to use as the fallback in case of a timeout
Returns
  • the new Maybe instance

public final Maybe<T> timeout (Publisher<U> timeoutIndicator)

If this Maybe source didn't signal an event before the timeoutIndicator Publisher signals, a TimeoutException is signalled instead.

Backpressure:
The timeoutIndicator Publisher is consumed in an unbounded manner and is cancelled after its first item.
Scheduler:
timeout does not operate by default on a particular Scheduler.

Parameters
timeoutIndicator the MaybeSource that indicates the timeout by signalling onSuccess or onComplete.
Returns
  • the new Maybe instance

public final Maybe<T> timeout (long timeout, TimeUnit timeUnit, Scheduler scheduler)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item, where this policy is governed on a specified Scheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Maybe terminates and notifies MaybeObservers of a TimeoutException.

Scheduler:
You specify which Scheduler this operator will use

Parameters
timeout maximum duration between items before a timeout occurs
timeUnit the unit of time that applies to the timeout argument
scheduler the Scheduler to run the timeout timers on
Returns
  • the new Maybe instance

public static Maybe<Long> timer (long delay, TimeUnit unit, Scheduler scheduler)

Returns a Maybe that emits 0L after a specified delay on a specified Scheduler.

Scheduler:
You specify which Scheduler this operator will use

Parameters
delay the initial delay before emitting a single 0L
unit time units to use for delay
scheduler the Scheduler to use for scheduling the item
Returns
  • a Maybe that emits 0L after a specified delay, on a specified Scheduler

public static Maybe<Long> timer (long delay, TimeUnit unit)

Returns a Maybe that emits 0L after a specified delay.

Scheduler:
timer operates by default on the computation Scheduler.

Parameters
delay the initial delay before emitting a single 0L
unit time units to use for delay
Returns
  • a Maybe that emits 0L after a specified delay

public final R to (Function<? super Maybe<T>, R> convert)

Calls the specified converter function with the current Maybe instance during assembly time and returns its result.

Scheduler:
to does not operate by default on a particular Scheduler.

Parameters
convert the function that is called with the current Maybe instance during assembly time that should return some value to be the result
Returns
  • the value returned by the convert function

public final Flowable<T> toFlowable ()

Converts this Maybe into a backpressure-aware Flowable instance composing cancellation through.

Backpressure:
The returned Flowable honors the backpressure of the downstream.
Scheduler:
toFlowable does not operate by default on a particular Scheduler.

Returns
  • the new Flowable instance

public final Observable<T> toObservable ()

Converts this Maybe into an Observable instance composing cancellation through.

Scheduler:
toObservable does not operate by default on a particular Scheduler.

Returns
  • the new Observable instance

public final Single<T> toSingle ()

Converts this Maybe into a Single instance composing cancellation through and turning an empty Maybe into a signal of NoSuchElementException.

Scheduler:
toSingle does not operate by default on a particular Scheduler.

Returns
  • the new Single instance

public final Single<T> toSingle (T defaultValue)

Converts this Maybe into a Single instance composing cancellation through and turning an empty Maybe into a Single that emits the given value through onSuccess.

Scheduler:
toSingle does not operate by default on a particular Scheduler.

Parameters
defaultValue the default item to signal in Single if this Maybe is empty
Returns
  • the new Single instance

public static Maybe<T> unsafeCreate (MaybeSource<T> onSubscribe)

Advanced use only: creates a Maybe instance without any safeguards by using a callback that is called with a MaybeObserver.

Scheduler:
unsafeCreate does not operate by default on a particular Scheduler.

Parameters
onSubscribe the function that is called with the subscribing MaybeObserver
Returns
  • the new Maybe instance

public final Maybe<T> unsubscribeOn (Scheduler scheduler)

Returns a Maybe which makes sure when a MaybeObserver disposes the Disposable, that call is propagated up on the specified scheduler

Scheduler:
unsubscribeOn calls dispose() of the upstream on the Scheduler you specify.

Parameters
scheduler the target scheduler where to execute the cancellation
Returns
  • the new Maybe instance
Throws
NullPointerException if scheduler is null

public static Maybe<T> using (Callable<? extends D> resourceSupplier, Function<? super D, ? extends MaybeSource<? extends T>> sourceSupplier, Consumer<? super D> resourceDisposer)

Constructs a Maybe that creates a dependent resource object which is disposed of when the upstream terminates or the downstream calls dispose().

Scheduler:
using does not operate by default on a particular Scheduler.

Parameters
resourceSupplier the factory function to create a resource object that depends on the Maybe
sourceSupplier the factory function to create a MaybeSource
resourceDisposer the function that will dispose of the resource
Returns
  • the Maybe whose lifetime controls the lifetime of the dependent resource object

public static Maybe<T> using (Callable<? extends D> resourceSupplier, Function<? super D, ? extends MaybeSource<? extends T>> sourceSupplier, Consumer<? super D> resourceDisposer, boolean eager)

Constructs a Maybe that creates a dependent resource object which is disposed of just before termination if you have set disposeEagerly to true and a downstream dispose() does not occur before termination. Otherwise resource disposal will occur on call to dispose(). Eager disposal is particularly appropriate for a synchronous Maybe that reuses resources. disposeAction will only be called once per subscription.

Scheduler:
using does not operate by default on a particular Scheduler.

Parameters
resourceSupplier the factory function to create a resource object that depends on the Maybe
sourceSupplier the factory function to create a MaybeSource
resourceDisposer the function that will dispose of the resource
eager if true then disposal will happen either on a dispose() call or just before emission of a terminal event (onComplete or onError).
Returns
  • the Maybe whose lifetime controls the lifetime of the dependent resource object

public static Maybe<T> wrap (MaybeSource<T> source)

Wraps a MaybeSource instance into a new Maybe instance if not already a Maybe instance.

Scheduler:
wrap does not operate by default on a particular Scheduler.

Parameters
source the source to wrap
Returns
  • the Maybe wrapper or the source cast to Maybe (if possible)

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, Function3<? super T1, ? super T2, ? super T3, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (Iterable<? extends MaybeSource<? extends T>> sources, Function<? super Object[], ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other MaybeSources.

Note on method signature: since Java doesn't allow creating a generic array with new T[], the implementation of this operator has to create an Object[] instead. Unfortunately, a Function<Integer[], R> passed to the method would trigger a ClassCastException.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
sources an Iterable of source MaybeSources
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, Function7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
source5 a fifth source MaybeSource
source6 a sixth source MaybeSource
source7 a seventh source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, BiFunction<? super T1, ? super T2, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
source5 a fifth source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, MaybeSource<? extends T8> source8, Function8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
source5 a fifth source MaybeSource
source6 a sixth source MaybeSource
source7 a seventh source MaybeSource
source8 an eighth source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, Function6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
source5 a fifth source MaybeSource
source6 a sixth source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, MaybeSource<? extends T5> source5, MaybeSource<? extends T6> source6, MaybeSource<? extends T7> source7, MaybeSource<? extends T8> source8, MaybeSource<? extends T9> source9, Function9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine other MaybeSources.

Scheduler:
zip does not operate by default on a particular Scheduler.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
source5 a fifth source MaybeSource
source6 a sixth source MaybeSource
source7 a seventh source MaybeSource
source8 an eighth source MaybeSource
source9 a ninth source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting MaybeSource
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zip (MaybeSource<? extends T1> source1, MaybeSource<? extends T2> source2, MaybeSource<? extends T3> source3, MaybeSource<? extends T4> source4, Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> zipper)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four other MaybeSources.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zip does not operate by default on a particular Scheduler.

Parameters
source1 the first source MaybeSource
source2 a second source MaybeSource
source3 a third source MaybeSource
source4 a fourth source MaybeSource
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting Maybe
Returns
  • a Maybe that emits the zipped results

public static Maybe<R> zipArray (Function<? super Object[], ? extends R> zipper, MaybeSource...<? extends T> sources)

Returns a Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of other MaybeSources.

Note on method signature: since Java doesn't allow creating a generic array with new T[], the implementation of this operator has to create an Object[] instead. Unfortunately, a Function<Integer[], R> passed to the method would trigger a ClassCastException.

This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This also means it is possible some sources may not get subscribed to at all.

Scheduler:
zipArray does not operate by default on a particular Scheduler.

Parameters
zipper a function that, when applied to an item emitted by each of the source MaybeSources, results in an item that will be emitted by the resulting MaybeSource
sources an array of source MaybeSources
Returns
  • a Maybe that emits the zipped results

public final Maybe<R> zipWith (MaybeSource<? extends U> other, BiFunction<? super T, ? super U, ? extends R> zipper)

Waits until this and the other MaybeSource signal a success value then applies the given BiFunction to those values and emits the BiFunction's resulting value to downstream.

If either this or the other MaybeSource is empty or signals an error, the resulting Maybe will terminate immediately and dispose the other source.

Scheduler:
zipWith does not operate by default on a particular Scheduler.

Parameters
other the other MaybeSource
zipper a function that combines the pairs of items from the two MaybeSources to generate the items to be emitted by the resulting Maybe
Returns
  • the new Maybe instance

Protected Methods

protected abstract void subscribeActual (MaybeObserver<? super T> observer)

Override this method in subclasses to handle the incoming MaybeObservers.

Parameters
observer the MaybeObserver to handle, not null