Top Description Constructors Methods
io.reactivex

public abstract Class Maybe<T>

extends Object
implements MaybeSource<T>
Class Inheritance
All Implemented Interfaces
io.reactivex.MaybeSource
Known Direct Subclasses
io.reactivex.internal.operators.flowable.FlowableLastMaybe, io.reactivex.internal.operators.flowable.FlowableSingleMaybe, io.reactivex.internal.operators.flowable.FlowableElementAtMaybe, io.reactivex.internal.operators.flowable.FlowableReduceMaybe, io.reactivex.internal.operators.maybe.AbstractMaybeWithUpstream, io.reactivex.internal.operators.maybe.MaybeAmb, io.reactivex.internal.operators.maybe.MaybeCache, io.reactivex.internal.operators.maybe.MaybeCreate, io.reactivex.internal.operators.maybe.MaybeDefer, io.reactivex.internal.operators.maybe.MaybeDelayWithCompletable, io.reactivex.internal.operators.maybe.MaybeFromRunnable, io.reactivex.internal.operators.maybe.MaybeFromSingle, io.reactivex.internal.operators.maybe.MaybeJust, io.reactivex.internal.operators.maybe.MaybeNever, io.reactivex.internal.operators.maybe.MaybeDoOnTerminate, io.reactivex.internal.operators.maybe.MaybeEmpty, io.reactivex.internal.operators.maybe.MaybeError, io.reactivex.internal.operators.maybe.MaybeErrorCallable, io.reactivex.internal.operators.maybe.MaybeFilterSingle, io.reactivex.internal.operators.maybe.MaybeFlatMapSingleElement, io.reactivex.internal.operators.maybe.MaybeFromAction, io.reactivex.internal.operators.maybe.MaybeFromCallable, io.reactivex.internal.operators.maybe.MaybeFromCompletable, io.reactivex.internal.operators.maybe.MaybeTimer, io.reactivex.internal.operators.maybe.MaybeUsing, io.reactivex.internal.operators.maybe.MaybeZipArray, io.reactivex.internal.operators.maybe.MaybeZipIterable, io.reactivex.internal.operators.maybe.MaybeFromFuture, io.reactivex.internal.operators.observable.ObservableReduceMaybe, io.reactivex.internal.operators.observable.ObservableSingleMaybe, io.reactivex.internal.operators.observable.ObservableElementAtMaybe, io.reactivex.internal.operators.observable.ObservableLastMaybe, io.reactivex.internal.operators.single.SingleDematerialize, io.reactivex.internal.operators.single.SingleFlatMapMaybe, io.reactivex.subjects.MaybeSubject
Type Parameters
<T>
the value type
Imports
java.util.NoSuchElementException, java.util.concurrent.*, org.reactivestreams.*, io.reactivex.annotations.*, io.reactivex.disposables.Disposable, io.reactivex.exceptions.Exceptions, io.reactivex.functions.*, io.reactivex.internal.functions.*, io.reactivex.internal.fuseable.*, io.reactivex.internal.observers.BlockingMultiObserver, io.reactivex.internal.operators.flowable.*, io.reactivex.internal.operators.maybe.*, io.reactivex.internal.operators.mixed.*, io.reactivex.internal.util.*, io.reactivex.observers.TestObserver, io.reactivex.plugins.RxJavaPlugins, io.reactivex.schedulers.Schedulers

The Maybe class represents a deferred computation and emission of a single value, no value at all or an exception.

The Maybe class implements the MaybeSource base interface and the default consumer type it interacts with is the MaybeObserver via the subscribe(MaybeObserver) method.

The Maybe operates with the following sequential protocol:


    onSubscribe (onSuccess | onError | onComplete)?

Note that onSuccess, onError and onComplete are mutually exclusive events; unlike Observable, onSuccess is never followed by onError or onComplete.

Like Observable, a running Maybe can be stopped through the Disposable instance provided to consumers through MaybeObserver#onSubscribe.

Like an Observable, a Maybe is lazy, can be either "hot" or "cold", synchronous or asynchronous. Maybe instances returned by the methods of this class are cold and there is a standard hot implementation in the form of a subject: MaybeSubject.

The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:

See Flowable or Observable for the implementation of the Reactive Pattern for a stream or vector of values.

Example:


Disposable d = Maybe.just("Hello World")
   .delay(10, TimeUnit.SECONDS, Schedulers.io())
   .subscribeWith(new DisposableMaybeObserver<String>() {
       @Override
       public void onStart() {
           System.out.println("Started");
       }

       @Override
       public void onSuccess(String value) {
           System.out.println("Success: " + value);
       }

       @Override
       public void onError(Throwable error) {
           error.printStackTrace();
       }

       @Override
       public void onComplete() {
           System.out.println("Done!");
       }
   });

Thread.sleep(5000);

d.dispose();

Note that by design, subscriptions via subscribe(MaybeObserver) can't be disposed from the outside (hence the void return of the subscribe(MaybeObserver) method) and it is the responsibility of the implementor of the MaybeObserver to allow this to happen. RxJava supports such usage with the standard DisposableMaybeObserver instance. For convenience, the subscribeWith(MaybeObserver) method is provided as well to allow working with a MaybeObserver (or subclass) instance to be applied with in a fluent manner (such as in the example above).

Since
2.0
See Also
io.reactivex.observers.DisposableMaybeObserver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
amb
(final Iterable<? extends MaybeSource<? extends T>>
the Iterable sequence of sources. A subscription to each source will occur in the same order as in the Iterable.
sources
)

Runs multiple MaybeSources and signals the events of the first one that signals (disposing the rest).

public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
ambArray
(final MaybeSource<? extends T>...
the array of sources. A subscription to each source will occur in the same order as in the array.
sources
)

Runs multiple MaybeSources and signals the events of the first one that signals (disposing the rest).

public final Maybe<T>

Returns:

a Maybe that emits the same sequence as whichever of the source MaybeSources first signalled
ambWith
(MaybeSource<? extends T>
a MaybeSource competing to react first. A subscription to this provided source will occur after subscribing to the current source.
other
)

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

public final <
the resulting object type
R
>
R

Returns:

the converted value
as
(MaybeConverter<T, ? extends R>
the function that receives the current Maybe instance and returns a value
converter
)

Calls the specified converter function during assembly time and returns its resulting value.

public final T

Returns:

the success value
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).

public final T

Returns:

the success value
blockingGet
(T
the default item to return if this Maybe is empty
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).

public final Maybe<T>

Returns:

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

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

public final <
the target type
U
>
Maybe<U>

Returns:

the new Maybe instance
cast
(final Class<? extends U>
the type token to use for casting the success result from the current Maybe
clazz
)

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

public final <
the value type of the Maybe returned by the transformer function
R
>
Maybe<R>

Returns:

a Maybe, transformed by the transformer function
compose
(MaybeTransformer<? super T, ? extends R>
the transformer function, not null
transformer
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance
concat
(Iterable<? extends MaybeSource<? extends T>>
the Iterable sequence of MaybeSource instances
sources
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits items emitted by the two source MaybeSources, one after the other.
concat
(MaybeSource<? extends T>
a MaybeSource to be concatenated
source1
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source2
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits items emitted by the three source MaybeSources, one after the other.
concat
(MaybeSource<? extends T>
a MaybeSource to be concatenated
source1
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source2
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source3
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits items emitted by the four source MaybeSources, one after the other.
concat
(MaybeSource<? extends T>
a MaybeSource to be concatenated
source1
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source2
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source3
,
MaybeSource<? extends T>
a MaybeSource to be concatenated
source4
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance
concat
(Publisher<? extends MaybeSource<? extends T>>
the Publisher of MaybeSource instances
sources
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance
concat
(Publisher<? extends MaybeSource<? extends T>>
the Publisher of MaybeSource instances
sources
,
int
the number of MaybeSources to prefetch from the Publisher
prefetch
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance
concatArray
(MaybeSource<? extends T>...
the array of MaybeSource instances
sources
)

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

public static <
the common base value type
T
>
Flowable<T>

Returns:

the new Flowable instance
concatArrayDelayError
(MaybeSource<? extends T>...
the array of sources
sources
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance with the specified concatenation behavior
concatArrayEager
(MaybeSource<? extends T>...
a sequence of MaybeSources that need to be eagerly concatenated
sources
)

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

public static <
the common element base type
T
>
Flowable<T>

Returns:

the new Flowable with the concatenating behavior
concatDelayError
(Iterable<? extends MaybeSource<? extends T>>
the Iterable sequence of MaybeSources
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.

public static <
the common element base type
T
>
Flowable<T>

Returns:

the new Publisher with the concatenating behavior
concatDelayError
(Publisher<? extends MaybeSource<? extends T>>
the Publisher sequence of Publishers
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.

public static <
the value type
T
>
Flowable<T>

Returns:

the new Flowable instance with the specified concatenation behavior
concatEager
(Iterable<? extends MaybeSource<? extends T>>
a sequence of MaybeSource that need to be eagerly concatenated
sources
)

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

public static <
the value type
T
>
Flowable<T>

Returns:

the new Publisher instance with the specified concatenation behavior
concatEager
(Publisher<? extends MaybeSource<? extends T>>
a sequence of Publishers that need to be eagerly concatenated
sources
)

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

public final <
the result value type
R
>
Maybe<R>

Returns:

the Maybe returned from func when applied to the item emitted by the source Maybe
concatMap
(Function<? super T, ? extends MaybeSource<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns a MaybeSource
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.

public final Flowable<T>

Returns:

a Flowable that emits items emitted by the two source MaybeSources, one after the other, without interleaving them
concatWith
(MaybeSource<? extends T>
a MaybeSource to be concatenated after the current
other
)

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

public final Single<Boolean>

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
contains
(final Object
the item to search for in the emissions from the source Maybe, not null
item
)

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

public final Single<Long>

Returns:

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

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

public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
create
(MaybeOnSubscribe<T>
the emitter that is called when a MaybeObserver subscribes to the returned Maybe
onSubscribe
)

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

public final Maybe<T>

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
defaultIfEmpty
(T
the item to emit if the source Maybe emits no items
defaultItem
)

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

public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
defer
(final Callable<? extends MaybeSource<? extends T>>
the Callable that is called for each individual MaybeObserver and returns a MaybeSource instance to subscribe to
maybeSupplier
)

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

public final Maybe<T>

Returns:

the new Maybe instance
delay
(long
the delay to shift the source by
delay
,
TimeUnit
the TimeUnit in which period is defined
unit
)

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

public final Maybe<T>

Returns:

the new Maybe instance
delay
(long
the delay to shift the source by
delay
,
TimeUnit
the time unit of delay
unit
,
Scheduler
the Scheduler to use for delaying
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.

public final <
the subscription delay value type (ignored)
U
,
the item delay value type (ignored)
V
>
Maybe<T>

Returns:

the new Maybe instance
delay
(Publisher<U>
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
delayIndicator
)

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

public final <
the value type of the other Publisher, irrelevant
U
>
Maybe<T>

Returns:

a Maybe that delays the subscription to this Maybe until the other Publisher emits an element or completes normally.
delaySubscription
(Publisher<U>
the other Publisher that should trigger the subscription to this Publisher.
subscriptionIndicator
)

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

public final Maybe<T>

Returns:

a Maybe that delays the subscription to the source Maybe by the given amount
delaySubscription
(long
the time to delay the subscription
delay
,
TimeUnit
the time unit of delay
unit
)

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

public final Maybe<T>

Returns:

a Maybe that delays the subscription to the source Maybe by a given amount, waiting and subscribing on the given Scheduler
delaySubscription
(long
the time to delay the subscription
delay
,
TimeUnit
the time unit of delay
unit
,
Scheduler
the Scheduler on which the waiting and subscription will happen
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.

public final Maybe<T>

Returns:

the new Maybe instance
doAfterSuccess
(Consumer<? super T>
the Consumer that will be called after emitting an item from upstream to the downstream
onAfterSuccess
)

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

public final Maybe<T>

Returns:

a Maybe that emits the same items as the source Maybe, then invokes the Action
doAfterTerminate
(Action
an Action to be invoked when the source Maybe finishes
onAfterTerminate
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doFinally
(Action
the action called when this Maybe terminates or gets disposed
onFinally
)

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

public final Maybe<T>

Returns:

the new Maybe with the side-effecting behavior applied
doOnComplete
(Action
the action to invoke when the source Maybe calls onComplete
onComplete
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doOnDispose
(Action
the action called when the subscription is disposed
onDispose
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doOnError
(Consumer<? super Throwable>
the consumer called with the success value of onError
onError
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doOnEvent
(BiConsumer<? super T, ? super Throwable>
the callback to call with the terminal event tuple
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.

public final Maybe<T>

Returns:

the new Maybe instance
doOnSubscribe
(Consumer<? super Disposable>
the consumer called with the Disposable sent via onSubscribe
onSubscribe
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doOnSuccess
(Consumer<? super T>
the consumer called with the success value of onSuccess
onSuccess
)

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

public final Maybe<T>

Returns:

the new Maybe instance
doOnTerminate
(final Action
the action to invoke when the consumer calls onComplete or onError
onTerminate
)

Returns a Maybe instance that calls the given onTerminate callback just before this Maybe completes normally or with an exception.

public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
empty
()

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

public static <
the type of the item (ostensibly) emitted by the Maybe
T
>
Maybe<T>

Returns:

a Maybe that invokes the subscriber's onError method when the subscriber subscribes to it
error
(Throwable
the particular Throwable to pass to onError
exception
)

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

public static <
the type of the items (ostensibly) emitted by the Maybe
T
>
Maybe<T>

Returns:

a Maybe that invokes the MaybeObserver's onError method when the MaybeObserver subscribes to it
error
(Callable<? extends Throwable>
a Callable factory to return a Throwable for each individual MaybeObserver
supplier
)

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

public final Maybe<T>

Returns:

a Maybe that emit the item emitted by the source Maybe that the filter evaluates as true
filter
(Predicate<? super T>
a function that evaluates the item emitted by the source Maybe, returning true if it passes the filter
predicate
)

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

public final <
the result value type
R
>
Maybe<R>

Returns:

the Maybe returned from func when applied to the item emitted by the source Maybe
flatMap
(Function<? super T, ? extends MaybeSource<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns a MaybeSource
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.

public final <
the result type
R
>
Maybe<R>

Returns:

the new Maybe instance
flatMap
(Function<? super T, ? extends MaybeSource<? extends R>>
a function that returns a MaybeSource to merge for the onSuccess item emitted by this Maybe
onSuccessMapper
,
Function<? super Throwable, ? extends MaybeSource<? extends R>>
a function that returns a MaybeSource to merge for an onError notification from this Maybe
onErrorMapper
,
Callable<? extends MaybeSource<? extends R>>
a function that returns a MaybeSource to merge for an onComplete notification this Maybe
onCompleteSupplier
)

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

public final <
the type of items emitted by the MaybeSource returned by the mapper function
U
,
the type of items emitted by the resulting Maybe
R
>
Maybe<R>

Returns:

the new Maybe instance
flatMap
(Function<? super T, ? extends MaybeSource<? extends U>>
a function that returns a MaybeSource for the item emitted by the source Maybe
mapper
,
BiFunction<? super T, ? super U, ? extends R>
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
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.

public final Completable

Returns:

the Completable returned from mapper when applied to the item emitted by the source Maybe
flatMapCompletable
(final Function<? super T, ? extends CompletableSource>
a function that, when applied to the item emitted by the source Maybe, returns a Completable
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.

public final <
the result value type
R
>
Observable<R>

Returns:

the Observable returned from func when applied to the item emitted by the source Maybe
flatMapObservable
(Function<? super T, ? extends ObservableSource<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns an ObservableSource
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.

public final <
the result value type
R
>
Flowable<R>

Returns:

the Flowable returned from func when applied to the item emitted by the source Maybe
flatMapPublisher
(Function<? super T, ? extends Publisher<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns a Flowable
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.

public final <
the result value type
R
>
Single<R>

Returns:

the Single returned from mapper when applied to the item emitted by the source Maybe
flatMapSingle
(final Function<? super T, ? extends SingleSource<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns a Single
mapper
)

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

public final <
the result value type
R
>
Maybe<R>

Returns:

the new Maybe instance
flatMapSingleElement
(final Function<? super T, ? extends SingleSource<? extends R>>
a function that, when applied to the item emitted by the source Maybe, returns a Single
mapper
)

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

public final <
the type of item emitted by the resulting Iterable
U
>
Flowable<U>

Returns:

the new Flowable instance
flattenAsFlowable
(final Function<? super T, ? extends Iterable<? extends U>>
a function that returns an Iterable sequence of values for when given an item emitted by the source Maybe
mapper
)

Maps the success value of the upstream Maybe into an Iterable and emits its items as a Flowable sequence.

public final <
the type of item emitted by the resulting Iterable
U
>
Observable<U>

Returns:

the new Observable instance
flattenAsObservable
(final Function<? super T, ? extends Iterable<? extends U>>
a function that returns an Iterable sequence of values for when given an item emitted by the source Maybe
mapper
)

Maps the success value of the upstream Maybe into an Iterable and emits its items as an Observable sequence.

public static <
the target type
T
>
Maybe<T>

Returns:

the new Maybe instance
fromAction
(final Action
the runnable to run for each subscriber
run
)

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

public static <
the type of the item emitted by the Maybe.
T
>
Maybe<T>

Returns:

a new Maybe instance
fromCallable
(final Callable<? extends T>
a Callable instance whose execution should be deferred and performed for each individual MaybeObserver that subscribes to the returned Maybe.
callable
)

Returns a Maybe that invokes the given Callable for each individual MaybeObserver that subscribes and emits the resulting non-null item via onSuccess while considering a null result from the Callable as indication for valueless completion via onComplete.

public static <
the target type
T
>
Maybe<T>

Returns:

the new Maybe instance
fromCompletable
(CompletableSource
the CompletableSource to convert from
completableSource
)

Wraps a CompletableSource into a Maybe.

public static <
the type of object that the Future returns, and also the type of item to be emitted by the resulting Maybe
T
>
Maybe<T>

Returns:

a Maybe that emits the item from the source Future
fromFuture
(Future<? extends T>
the source Future
future
)

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

public static <
the type of object that the Future returns, and also the type of item to be emitted by the resulting Maybe
T
>
Maybe<T>

Returns:

a Maybe that emits the item from the source Future
fromFuture
(Future<? extends T>
the source Future
future
,
long
the maximum time to wait before calling get
timeout
,
TimeUnit
the TimeUnit of the timeout argument
unit
)

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

public static <
the target type
T
>
Maybe<T>

Returns:

the new Maybe instance
fromRunnable
(final Runnable
the runnable to run for each subscriber
run
)

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

public static <
the target type
T
>
Maybe<T>

Returns:

the new Maybe instance
fromSingle
(SingleSource<T>
the SingleSource to convert from
singleSource
)

Wraps a SingleSource into a Maybe.

public final Maybe<T>

Returns:

the new Maybe instance
hide
()

Hides the identity of this Maybe and its Disposable.

public final Completable

Returns:

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

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

public final Single<Boolean>

Returns:

a Single that emits a Boolean
isEmpty
()

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

public static <
the type of that item
T
>
Maybe<T>

Returns:

a Maybe that emits item
just
(T
the item to emit
item
)

Returns a Maybe that emits a specified item.

public final <
the output value type
R
>
Maybe<R>

Returns:

the new Maybe instance
lift
(final MaybeOperator<? extends R, ? super T>
the MaybeOperator that receives the downstream's MaybeObserver and should return a MaybeObserver with custom behavior to be used as the consumer for the current Maybe.
lift
)

This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns a Maybe which, when subscribed to, invokes the apply(MaybeObserver) method of the provided MaybeOperator for each individual downstream Maybe and allows the insertion of a custom operator by accessing the downstream's MaybeObserver during this subscription phase and providing a new MaybeObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.

public final <
the result value type
R
>
Maybe<R>

Returns:

a Maybe that emits the item from the source Maybe, transformed by the specified function
map
(Function<? super T, ? extends R>
a function to apply to the item emitted by the Maybe
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.

public final Single<Notification<T>>

Returns:

the new Single instance
materialize
()

Maps the signal types of this Maybe into a Notification of the same kind and emits it as a single success value to downstream.

public static <
the common and resulting value type
T
>
Flowable<T>

Returns:

the new Flowable instance
merge
(Iterable<? extends MaybeSource<? extends T>>
the Iterable sequence of MaybeSource sources
sources
)

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

public static <
the common and resulting value type
T
>
Flowable<T>

Returns:

the new Flowable instance
merge
(Publisher<? extends MaybeSource<? extends T>>
the Flowable sequence of MaybeSource sources
sources
)

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

public static <
the common and resulting value type
T
>
Flowable<T>

Returns:

the new Flowable instance
merge
(Publisher<? extends MaybeSource<? extends T>>
the Flowable sequence of MaybeSource sources
sources
,
int
the maximum number of concurrently running MaybeSources
maxConcurrency
)

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

public static <
the value type of the sources and the output
T
>
Maybe<T>

Returns:

a Maybe that emits the item that is the result of flattening the MaybeSource emitted by source
merge
(MaybeSource<? extends MaybeSource<? extends T>>
a MaybeSource that emits a MaybeSource
source
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items emitted by the source MaybeSources
merge
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
source2
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items emitted by the source MaybeSources
merge
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
source2
,
MaybeSource<? extends T>
a MaybeSource to be merged
source3
)

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

public static <
the common value type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items emitted by the source MaybeSources
merge
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
source2
,
MaybeSource<? extends T>
a MaybeSource to be merged
source3
,
MaybeSource<? extends T>
a MaybeSource to be merged
source4
)

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

public static <
the common and resulting value type
T
>
Flowable<T>

Returns:

the new Flowable instance
mergeArray
(MaybeSource<? extends T>...
the array sequence of MaybeSource sources
sources
)

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

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits items that are the result of flattening the items emitted by the MaybeSources in the Iterable
mergeArrayDelayError
(MaybeSource<? extends T>...
the Iterable of MaybeSources
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.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits items that are the result of flattening the items emitted by the MaybeSources in the Iterable
mergeDelayError
(Iterable<? extends MaybeSource<? extends T>>
the Iterable of MaybeSources
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.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items emitted by the Publishers emitted by the source Publisher
mergeDelayError
(Publisher<? extends MaybeSource<? extends T>>
a Publisher that emits MaybeSources
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 MaybeSources without being interrupted by an error notification from one of them or even the main Publisher.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items emitted by the Publishers emitted by the source Publisher
mergeDelayError
(Publisher<? extends MaybeSource<? extends T>>
a Publisher that emits MaybeSources
sources
,
int
the maximum number of active inner MaybeSources to be merged at a time
maxConcurrency
)

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 MaybeSources without being interrupted by an error notification from one of them or even the main Publisher as well as limiting the total number of active MaybeSources.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items that are emitted by the two source MaybeSources
mergeDelayError
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
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.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items that are emitted by the source MaybeSources
mergeDelayError
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
source2
,
MaybeSource<? extends T>
a MaybeSource to be merged
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.

public static <
the common element base type
T
>
Flowable<T>

Returns:

a Flowable that emits all of the items that are emitted by the source MaybeSources
mergeDelayError
(MaybeSource<? extends T>
a MaybeSource to be merged
source1
,
MaybeSource<? extends T>
a MaybeSource to be merged
source2
,
MaybeSource<? extends T>
a MaybeSource to be merged
source3
,
MaybeSource<? extends T>
a MaybeSource to be merged
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.

public final Flowable<T>

Returns:

a new Flowable instance
mergeWith
(MaybeSource<? extends T>
a MaybeSource to be merged
other
)

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

public static <
the type of items (not) emitted by the Maybe
T
>
Maybe<T>

Returns:

a Maybe that never emits any items or sends any notifications to a MaybeObserver
never
()

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

public final Maybe<T>

Returns:

the new Maybe instance that its subscribers are notified on the specified Scheduler
observeOn
(final Scheduler
the Scheduler to notify subscribers on
scheduler
)

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

public final <
the output type
U
>
Maybe<U>

Returns:

the new Maybe instance
ofType
(final Class<U>
the class type to filter the items emitted by the source Maybe
clazz
)

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

public final Maybe<T>

Returns:

the new Maybe instance
onErrorComplete
()

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

public final Maybe<T>

Returns:

the new Maybe instance
onErrorComplete
(final Predicate<? super Throwable>
the predicate to call when an Throwable is emitted which should return true if the Throwable should be swallowed and replaced with an onComplete.
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.

public final Maybe<T>

Returns:

the new Maybe instance
onErrorResumeNext
(final MaybeSource<? extends T>
the next MaybeSource that will take over if the source Maybe encounters an error
next
)

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

public final Maybe<T>

Returns:

the new Maybe instance
onErrorResumeNext
(Function<? super Throwable, ? extends MaybeSource<? extends T>>
a function that returns a MaybeSource that will take over if the source Maybe encounters an error
resumeFunction
)

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

public final Maybe<T>

Returns:

the new Maybe instance
onErrorReturn
(Function<? super Throwable, ? extends T>
a function that returns a single value that will be emitted as success value the current Maybe signals an onError event
valueSupplier
)

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

public final Maybe<T>

Returns:

the new Maybe instance
onErrorReturnItem
(final T
the value that is emitted as onSuccess in case this Maybe signals an onError
item
)

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

public final Maybe<T>

Returns:

the new Maybe instance
onExceptionResumeNext
(final MaybeSource<? extends T>
the next MaybeSource that will take over if the source Maybe encounters an exception
next
)

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

public final Maybe<T>

Returns:

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

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

public final Flowable<T>

Returns:

a Flowable that emits the items emitted by the source Maybe repeatedly and in sequence
repeat
()

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

public final Flowable<T>

Returns:

a Flowable that repeats the sequence of items emitted by the source Maybe at most count times
repeat
(long
the number of times the source Maybe items are repeated, a count of 0 will yield an empty sequence
times
)

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

public final Flowable<T>

Returns:

the new Flowable instance
repeatUntil
(BooleanSupplier
a boolean supplier that is called when the current Flowable completes and unless it returns false, the current Flowable is resubscribed
stop
)

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

public final Flowable<T>

Returns:

the source Publisher modified with repeat logic
repeatWhen
(final Function<? super Flowable<Object>, ? extends Publisher<?>>
receives a Publisher of notifications with which a user can complete or error, aborting the repeat.
handler
)

Returns a Flowable that emits the same values as the source Publisher with the exception of an onComplete.

public final Maybe<T>

Returns:

the new Maybe instance
retry
()

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

public final Maybe<T>

Returns:

the new Maybe instance
retry
(BiPredicate<? super Integer, ? super Throwable>
the predicate that determines if a resubscription may happen in case of a specific exception and retry count
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.

public final Maybe<T>

Returns:

the new Maybe instance
retry
(long
the number of times to resubscribe if the current Maybe fails
count
)

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

public final Maybe<T>

Returns:

the new Maybe instance
retry
(long
the number of times to resubscribe if the current Maybe fails
times
,
Predicate<? super Throwable>
the predicate called with the failure Throwable and should return true to trigger a retry.
predicate
)

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

public final Maybe<T>

Returns:

the new Maybe instance
retry
(Predicate<? super Throwable>
the predicate that receives the failure Throwable and should return true to trigger a retry.
predicate
)

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

public final Maybe<T>

Returns:

the new Maybe instance
retryUntil
(final BooleanSupplier
the function that should return true to stop retrying
stop
)

Retries until the given stop function returns true.

public final Maybe<T>

Returns:

the new Maybe instance
retryWhen
(final Function<? super Flowable<Throwable>, ? extends Publisher<?>>
receives a Publisher of notifications with which a user can complete or error, aborting the retry
handler
)

Returns a Maybe that emits the same values as the source Maybe with the exception of an onError.

public static <
the type of items emitted by each MaybeSource
T
>
Single<Boolean>

Returns:

a Single that emits a Boolean value that indicates whether the two sequences are the same
sequenceEqual
(MaybeSource<? extends T>
the first MaybeSource to compare
source1
,
MaybeSource<? extends T>
the second MaybeSource to compare
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.

public static <
the type of items emitted by each MaybeSource
T
>
Single<Boolean>

Returns:

a Single that emits a Boolean value that indicates whether the two MaybeSource sequences are the same according to the specified function
sequenceEqual
(MaybeSource<? extends T>
the first MaybeSource to compare
source1
,
MaybeSource<? extends T>
the second MaybeSource to compare
source2
,
BiPredicate<? super T, ? super T>
a function used to compare items emitted by each MaybeSource
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.

public final Disposable

Returns:

a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
subscribe
()

Subscribes to a Maybe and ignores onSuccess and onComplete emissions.

public final Disposable

Returns:

a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
subscribe
(Consumer<? super T>
the Consumer<T> you have designed to accept a success value from the Maybe
onSuccess
)

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

public final Disposable

Returns:

a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
subscribe
(Consumer<? super T>
the Consumer<T> you have designed to accept a success value from the Maybe
onSuccess
,
Consumer<? super Throwable>
the Consumer<Throwable> you have designed to accept any error notification from the Maybe
onError
)

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

public final Disposable

Returns:

a Disposable reference with which the caller can stop receiving items before the Maybe has finished sending them
subscribe
(Consumer<? super T>
the Consumer<T> you have designed to accept a success value from the Maybe
onSuccess
,
Consumer<? super Throwable>
the Consumer<Throwable> you have designed to accept any error notification from the Maybe
onError
,
Action
the Action you have designed to accept a completion notification from the Maybe
onComplete
)

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

public final void
subscribe(MaybeObserver<? super T>
the MaybeObserver, not null
observer
)

Implements io.reactivex.MaybeSource.subscribe.

Subscribes the given MaybeObserver to this MaybeSource instance.
protected abstract void
subscribeActual(MaybeObserver<? super T>
the MaybeObserver to handle, not null
observer
)

Implement this method in subclasses to handle the incoming MaybeObservers.

public final Maybe<T>

Returns:

the new Maybe instance that its subscriptions happen on the specified Scheduler
subscribeOn
(Scheduler
the Scheduler to perform subscription actions on
scheduler
)

Asynchronously subscribes subscribers to this Maybe on the specified Scheduler.

public final <
the type of the MaybeObserver to use and return
E extends MaybeObserver<? super T>
>
E

Returns:

the input subscriber
subscribeWith
(E
the MaybeObserver (subclass) to use and return, not null
observer
)

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

public final Maybe<T>

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.
switchIfEmpty
(MaybeSource<? extends T>
the alternate MaybeSource to subscribe to if the main does not emit any items
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.

public final Single<T>

Returns:

a Single that emits the items emitted by the source Maybe or the item of an alternate SingleSource if the source Maybe is empty.
switchIfEmpty
(SingleSource<? extends T>
the alternate SingleSource to subscribe to if the main does not emit any items
other
)

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

public final <
the type of items emitted by other
U
>
Maybe<T>

Returns:

a Maybe that emits the items emitted by the source Maybe until such time as other emits its first item
takeUntil
(MaybeSource<U>
the MaybeSource whose first emitted item will cause takeUntil to stop emitting items from the source Maybe
other
)

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

public final <
the type of items emitted by other
U
>
Maybe<T>

Returns:

a Maybe that emits the items emitted by the source Maybe until such time as other emits its first item
takeUntil
(Publisher<U>
the Publisher whose first emitted item will cause takeUntil to stop emitting items from the source Publisher
other
)

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

public final TestObserver<T>

Returns:

the new TestObserver instance
test
()

Creates a TestObserver and subscribes it to this Maybe.

public final TestObserver<T>

Returns:

the new TestObserver instance
test
(boolean
if true, the TestObserver will be cancelled before subscribing to this Maybe.
cancelled
)

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

public final Maybe<T>

Returns:

the new Maybe instance
timeout
(long
maximum duration between emitted items before a timeout occurs
timeout
,
TimeUnit
the unit of time that applies to the timeout argument.
timeUnit
)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item.

public final Maybe<T>

Returns:

the new Maybe instance
timeout
(long
maximum duration between items before a timeout occurs
timeout
,
TimeUnit
the unit of time that applies to the timeout argument
timeUnit
,
MaybeSource<? extends T>
the fallback MaybeSource to use in case of a timeout
fallback
)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item.

public final Maybe<T>

Returns:

the new Maybe instance
timeout
(long
maximum duration between items before a timeout occurs
timeout
,
TimeUnit
the unit of time that applies to the timeout argument
timeUnit
,
Scheduler
the Scheduler to run the timeout timers on
scheduler
,
MaybeSource<? extends T>
the MaybeSource to use as the fallback in case of a timeout
fallback
)

Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted item using a specified Scheduler.

public final Maybe<T>

Returns:

the new Maybe instance
timeout
(long
maximum duration between items before a timeout occurs
timeout
,
TimeUnit
the unit of time that applies to the timeout argument
timeUnit
,
Scheduler
the Scheduler to run the timeout timers on
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.

public final <
the value type of the
U
>
Maybe<T>

Returns:

the new Maybe instance
timeout
(MaybeSource<U>
the MaybeSource that indicates the timeout by signaling onSuccess or onComplete.
timeoutIndicator
)

If the current Maybe didn't signal an event before the timeoutIndicator MaybeSource signals, a TimeoutException is signaled instead.

public final <
the value type of the
U
>
Maybe<T>

Returns:

the new Maybe instance
timeout
(MaybeSource<U>
the MaybeSource that indicates the timeout by signaling onSuccess or onComplete.
timeoutIndicator
,
MaybeSource<? extends T>
the MaybeSource that is subscribed to if the current Maybe times out
fallback
)

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

public final <
the value type of the
U
>
Maybe<T>

Returns:

the new Maybe instance
timeout
(Publisher<U>
the MaybeSource that indicates the timeout by signaling onSuccess or onComplete.
timeoutIndicator
)

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

public final <
the value type of the
U
>
Maybe<T>

Returns:

the new Maybe instance
timeout
(Publisher<U>
the MaybeSource that indicates the timeout by signaling onSuccess or onComplete
timeoutIndicator
,
MaybeSource<? extends T>
the MaybeSource that is subscribed to if the current Maybe times out
fallback
)

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

public static Maybe<Long>

Returns:

a Maybe that emits 0L after a specified delay
timer
(long
the initial delay before emitting a single 0L
delay
,
TimeUnit
time units to use for delay
unit
)

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

public static Maybe<Long>

Returns:

a Maybe that emits 0L after a specified delay, on a specified Scheduler
timer
(long
the initial delay before emitting a single 0L
delay
,
TimeUnit
time units to use for delay
unit
,
Scheduler
the Scheduler to use for scheduling the item
scheduler
)

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

public final <
the result type
R
>
R

Returns:

the value returned by the convert function
to
(Function<? super Maybe<T>, R>
the function that is called with the current Maybe instance during assembly time that should return some value to be the result
convert
)

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

public final Flowable<T>

Returns:

the new Flowable instance
toFlowable
()

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

public final Observable<T>

Returns:

the new Observable instance
toObservable
()

Converts this Maybe into an Observable instance composing disposal through.

public final Single<T>

Returns:

the new Single instance
toSingle
(T
the default item to signal in Single if this Maybe is empty
defaultValue
)

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

public final Single<T>

Returns:

the new Single instance
toSingle
()

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

public static <
the value type
T
>
Maybe<T>

Returns:

the new Maybe instance
unsafeCreate
(MaybeSource<T>
the function that is called with the subscribing MaybeObserver
onSubscribe
)

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

public final Maybe<T>

Returns:

the new Maybe instance
unsubscribeOn
(final Scheduler
the target scheduler where to execute the disposal
scheduler
)

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

public static <
the element type of the generated MaybeSource
T
,
the type of the resource associated with the output sequence
D
>
Maybe<T>

Returns:

the Maybe whose lifetime controls the lifetime of the dependent resource object
using
(Callable<? extends D>
the factory function to create a resource object that depends on the Maybe
resourceSupplier
,
Function<? super D, ? extends MaybeSource<? extends T>>
the factory function to create a MaybeSource
sourceSupplier
,
Consumer<? super D>
the function that will dispose of the resource
resourceDisposer
)

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

public static <
the element type of the generated MaybeSource
T
,
the type of the resource associated with the output sequence
D
>
Maybe<T>

Returns:

the Maybe whose lifetime controls the lifetime of the dependent resource object
using
(Callable<? extends D>
the factory function to create a resource object that depends on the Maybe
resourceSupplier
,
Function<? super D, ? extends MaybeSource<? extends T>>
the factory function to create a MaybeSource
sourceSupplier
,
Consumer<? super D>
the function that will dispose of the resource
resourceDisposer
,
boolean
if true then disposal will happen either on a dispose() call or just before emission of a terminal event (onComplete or onError).
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.

public static <
the value type
T
>
Maybe<T>

Returns:

the Maybe wrapper or the source cast to Maybe (if possible)
wrap
(MaybeSource<T>
the source to wrap
source
)

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

public static <
the common value type
T
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(Iterable<? extends MaybeSource<? extends T>>
an Iterable of source MaybeSources
sources
,
Function<? super Object[], ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
BiFunction<? super T1, ? super T2, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
Function3<? super T1, ? super T2, ? super T3, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
Function4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the value type of the fifth source
T5
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
MaybeSource<? extends T5>
a fifth source MaybeSource
source5
,
Function5<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the value type of the fifth source
T5
,
the value type of the sixth source
T6
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
MaybeSource<? extends T5>
a fifth source MaybeSource
source5
,
MaybeSource<? extends T6>
a sixth source MaybeSource
source6
,
Function6<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the value type of the fifth source
T5
,
the value type of the sixth source
T6
,
the value type of the seventh source
T7
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
MaybeSource<? extends T5>
a fifth source MaybeSource
source5
,
MaybeSource<? extends T6>
a sixth source MaybeSource
source6
,
MaybeSource<? extends T7>
a seventh source MaybeSource
source7
,
Function7<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the value type of the fifth source
T5
,
the value type of the sixth source
T6
,
the value type of the seventh source
T7
,
the value type of the eighth source
T8
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
MaybeSource<? extends T5>
a fifth source MaybeSource
source5
,
MaybeSource<? extends T6>
a sixth source MaybeSource
source6
,
MaybeSource<? extends T7>
a seventh source MaybeSource
source7
,
MaybeSource<? extends T8>
an eighth source MaybeSource
source8
,
Function8<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R>
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
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.

public static <
the value type of the first source
T1
,
the value type of the second source
T2
,
the value type of the third source
T3
,
the value type of the fourth source
T4
,
the value type of the fifth source
T5
,
the value type of the sixth source
T6
,
the value type of the seventh source
T7
,
the value type of the eighth source
T8
,
the value type of the ninth source
T9
,
the zipped result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zip
(MaybeSource<? extends T1>
the first source MaybeSource
source1
,
MaybeSource<? extends T2>
a second source MaybeSource
source2
,
MaybeSource<? extends T3>
a third source MaybeSource
source3
,
MaybeSource<? extends T4>
a fourth source MaybeSource
source4
,
MaybeSource<? extends T5>
a fifth source MaybeSource
source5
,
MaybeSource<? extends T6>
a sixth source MaybeSource
source6
,
MaybeSource<? extends T7>
a seventh source MaybeSource
source7
,
MaybeSource<? extends T8>
an eighth source MaybeSource
source8
,
MaybeSource<? extends T9>
a ninth source MaybeSource
source9
,
Function9<? super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R>
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
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.

public static <
the common element type
T
,
the result type
R
>
Maybe<R>

Returns:

a Maybe that emits the zipped results
zipArray
(Function<? super Object[], ? extends R>
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
zipper
,
MaybeSource<? extends T>...
an array of source MaybeSources
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.

public final <
the type of items emitted by the other MaybeSource
U
,
the type of items emitted by the resulting Maybe
R
>
Maybe<R>

Returns:

the new Maybe instance
zipWith
(MaybeSource<? extends U>
the other MaybeSource
other
,
BiFunction<? super T, ? super U, ? extends R>
a function that combines the pairs of items from the two MaybeSources to generate the items to be emitted by the resulting Maybe
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait