Class Maybe<T>
- java.lang.Object
-
- io.reactivex.rxjava3.core.Maybe<T>
-
- Type Parameters:
T- the value type
- All Implemented Interfaces:
MaybeSource<T>
- Direct Known Subclasses:
AbstractMaybeWithUpstream,CompletableOnErrorReturn,FlowableElementAtMaybe,FlowableElementAtMaybePublisher,FlowableLastMaybe,FlowableReduceMaybe,FlowableSingleMaybe,MaybeAmb,MaybeCache,MaybeCreate,MaybeDefer,MaybeDelayWithCompletable,MaybeDoOnTerminate,MaybeEmpty,MaybeError,MaybeErrorCallable,MaybeFilterSingle,MaybeFlatMapSingle,MaybeFromAction,MaybeFromCallable,MaybeFromCompletable,MaybeFromCompletionStage,MaybeFromFuture,MaybeFromRunnable,MaybeFromSingle,MaybeFromSupplier,MaybeJust,MaybeMapOptional,MaybeNever,MaybeSubject,MaybeTimeInterval,MaybeTimer,MaybeUsing,MaybeZipArray,MaybeZipIterable,ObservableElementAtMaybe,ObservableLastMaybe,ObservableReduceMaybe,ObservableSingleMaybe,SingleDematerialize,SingleFlatMapMaybe,SingleMapOptional,SingleOnErrorComplete
public abstract class Maybe<@NonNull T> extends java.lang.Object implements MaybeSource<T>
TheMaybeclass represents a deferred computation and emission of a single value, no value at all or an exception.The
Maybeclass implements theMaybeSourcebase interface and the default consumer type it interacts with is theMaybeObservervia thesubscribe(MaybeObserver)method.The
Maybeoperates with the following sequential protocol:onSubscribe (onSuccess | onError | onComplete)?Note that
onSuccess,onErrorandonCompleteare mutually exclusive events; unlikeObservable,onSuccessis never followed byonErrororonComplete.Like
Observable, a runningMaybecan be stopped through theDisposableinstance provided to consumers throughMaybeObserver.onSubscribe(io.reactivex.rxjava3.disposables.Disposable).Like an
Observable, aMaybeis lazy, can be either "hot" or "cold", synchronous or asynchronous.Maybeinstances 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
FlowableorObservablefor 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 thevoidreturn of thesubscribe(MaybeObserver)method) and it is the responsibility of the implementor of theMaybeObserverto allow this to happen. RxJava supports such usage with the standardDisposableMaybeObserverinstance. For convenience, thesubscribeWith(MaybeObserver)method is provided as well to allow working with aMaybeObserver(or subclass) instance to be applied with in a fluent manner (such as in the example above).- Since:
- 2.0
- See Also:
DisposableMaybeObserver
-
-
Constructor Summary
Constructors Constructor Description Maybe()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <@NonNull T>
@NonNull Maybe<T>amb(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Runs multipleMaybeSources provided by anIterablesequence and signals the events of the first one that signals (disposing the rest).static <@NonNull T>
@NonNull Maybe<T>ambArray(@NonNull MaybeSource<? extends @NonNull T>... sources)Runs multipleMaybeSources and signals the events of the first one that signals (disposing the rest).@NonNull Maybe<T>ambWith(@NonNull MaybeSource<? extends @NonNull T> other)Mirrors theMaybeSource(current or provided) that first signals an event.TblockingGet()Waits in a blocking fashion until the currentMaybesignals a success value (which is returned),nullif completed or an exception (which is propagated).TblockingGet(@NonNull T defaultValue)Waits in a blocking fashion until the currentMaybesignals a success value (which is returned), defaultValue if completed or an exception (which is propagated).voidblockingSubscribe()Subscribes to the currentMaybeand blocks the current thread until it terminates.voidblockingSubscribe(@NonNull MaybeObserver<? super @NonNull T> observer)Subscribes to the currentMaybeand calls the appropriateMaybeObservermethod on the current thread.voidblockingSubscribe(@NonNull Consumer<? super @NonNull T> onSuccess)Subscribes to the currentMaybeand calls givenonSuccesscallback on the current thread when it completes normally.voidblockingSubscribe(@NonNull Consumer<? super @NonNull T> onSuccess, @NonNull Consumer<? super java.lang.Throwable> onError)Subscribes to the currentMaybeand calls the appropriate callback on the current thread when it terminates.voidblockingSubscribe(@NonNull Consumer<? super @NonNull T> onSuccess, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)Subscribes to the currentMaybeand calls the appropriate callback on the current thread when it terminates.@NonNull Maybe<T>cache()Returns aMaybethat subscribes to thisMaybelazily, caches its event and replays it, to all the downstream subscribers.<@NonNull U>
@NonNull Maybe<U>cast(@NonNull java.lang.Class<? extends @NonNull U> clazz)Casts the success value of the currentMaybeinto the target type or signals aClassCastExceptionif not compatible.<@NonNull R>
@NonNull Maybe<R>compose(@NonNull MaybeTransformer<? super @NonNull T,? extends @NonNull R> transformer)Transform aMaybeby applying a particularMaybeTransformerfunction to it.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2)Returns aFlowablethat emits the items emitted by twoMaybeSources, one after the other.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3)Returns aFlowablethat emits the items emitted by threeMaybeSources, one after the other.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull MaybeSource<? extends @NonNull T> source4)Returns aFlowablethat emits the items emitted by fourMaybeSources, one after the other.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by anIterablesequence as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by aPublishersequence as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int prefetch)Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by aPublishersequence as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatArray(@NonNull MaybeSource<? extends @NonNull T>... sources)Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources in the array as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatArrayDelayError(@NonNull MaybeSource<? extends @NonNull T>... sources)Concatenates a variable number ofMaybeSourcesources and delays errors from any of them till all terminate as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatArrayEager(@NonNull MaybeSource<? extends @NonNull T>... sources)Concatenates a sequence ofMaybeSourceeagerly into aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatArrayEagerDelayError(@NonNull MaybeSource<? extends @NonNull T>... sources)Concatenates a sequence ofMaybeSourceeagerly into aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Concatenates theIterablesequence ofMaybeSources into a single sequence by subscribing to eachMaybeSource, one after the other, one at a time and delays any errors till the all innerMaybeSources terminate as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Concatenates thePublishersequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisherterminate as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int prefetch)Concatenates thePublishersequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisherterminate as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence and runs a limited number of the inner sequences at once.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, running at most the given number of innerMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all innerMaybeSources terminate.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all innerMaybeSources terminate and runs a limited number of innerMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all the inner and the outer sequence terminate.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all the inner and the outer sequence terminate and runs a limited number of the innerMaybeSources at once.<@NonNull R>
@NonNull Maybe<R>concatMap(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)Returns aMaybethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.@NonNull CompletableconcatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)Returns aCompletablethat completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.<@NonNull R>
@NonNull Maybe<R>concatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)Returns aMaybebased on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle.@NonNull Flowable<T>concatWith(@NonNull MaybeSource<? extends @NonNull T> other)Returns aFlowablethat emits the items emitted from the currentMaybe, then theotherMaybeSource, one after the other, without interleaving them.@NonNull Single<java.lang.Boolean>contains(@NonNull java.lang.Object item)Returns aSinglethat emits aBooleanthat indicates whether the currentMaybeemitted a specified item.@NonNull Single<java.lang.Long>count()Returns aSinglethat counts the total number of items emitted (0 or 1) by the currentMaybeand emits this count as a 64-bitLong.static <@NonNull T>
@NonNull Maybe<T>create(@NonNull MaybeOnSubscribe<@NonNull T> onSubscribe)Provides an API (via a coldMaybe) that bridges the reactive world with the callback-style world.@NonNull Single<T>defaultIfEmpty(@NonNull T defaultItem)Returns aSinglethat emits the item emitted by the currentMaybeor a specified default item if the currentMaybeis empty.static <@NonNull T>
@NonNull Maybe<T>defer(@NonNull Supplier<? extends @NonNull MaybeSource<? extends @NonNull T>> supplier)Calls aSupplierfor each individualMaybeObserverto return the actualMaybeSourcesource to be subscribed to.@NonNull Maybe<T>delay(long time, @NonNull java.util.concurrent.TimeUnit unit)Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay.@NonNull Maybe<T>delay(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay.@NonNull Maybe<T>delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay.@NonNull Maybe<T>delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay running on the specifiedScheduler.<@NonNull U>
@NonNull Maybe<T>delay(@NonNull org.reactivestreams.Publisher<@NonNull U> delayIndicator)Delays the emission of thisMaybeuntil the givenPublishersignals an item or completes.@NonNull Maybe<T>delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit)Returns aMaybethat delays the subscription to the currentMaybeby a given amount of time.@NonNull Maybe<T>delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)Returns aMaybethat delays the subscription to the currentMaybeby a given amount of time, both waiting and subscribing on a givenScheduler.<@NonNull U>
@NonNull Maybe<T>delaySubscription(@NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator)Returns aMaybethat delays the subscription to thisMaybeuntil the otherPublisheremits an element or completes normally.<@NonNull R>
@NonNull Maybe<R>dematerialize(@NonNull Function<? super @NonNull T,@NonNull Notification<@NonNull R>> selector)Maps theNotificationsuccess value of the currentMaybeback into normalonSuccess,onErrororonCompletesignals.@NonNull Maybe<T>doAfterSuccess(@NonNull Consumer<? super @NonNull T> onAfterSuccess)Calls the specifiedConsumerwith the success item after this item has been emitted to the downstream.@NonNull Maybe<T>doAfterTerminate(@NonNull Action onAfterTerminate)@NonNull Maybe<T>doFinally(@NonNull Action onFinally)Calls the specified action after thisMaybesignalsonSuccess,onErrororonCompleteor gets disposed by the downstream.@NonNull Maybe<T>doOnComplete(@NonNull Action onComplete)@NonNull Maybe<T>doOnDispose(@NonNull Action onDispose)Calls the sharedActionif aMaybeObserversubscribed to the currentMaybedisposes the commonDisposableit received viaonSubscribe.@NonNull Maybe<T>doOnError(@NonNull Consumer<? super java.lang.Throwable> onError)Calls the sharedConsumerwith the error sent viaonErrorfor eachMaybeObserverthat subscribes to the currentMaybe.@NonNull Maybe<T>doOnEvent(@NonNull BiConsumer<? super @NonNull T,? super java.lang.Throwable> onEvent)Calls the givenonEventcallback with the (success value,null) for anonSuccess, (null, throwable) for anonErroror (null,null) for anonCompletesignal from thisMaybebefore delivering said signal to the downstream.@NonNull Maybe<T>doOnLifecycle(@NonNull Consumer<? super Disposable> onSubscribe, @NonNull Action onDispose)Calls the appropriateonXXXmethod (shared between allMaybeObservers) for the lifecycle events of the sequence (subscription, disposal).@NonNull Maybe<T>doOnSubscribe(@NonNull Consumer<? super Disposable> onSubscribe)Calls the sharedConsumerwith theDisposablesent through theonSubscribefor eachMaybeObserverthat subscribes to the currentMaybe.@NonNull Maybe<T>doOnSuccess(@NonNull Consumer<? super @NonNull T> onSuccess)Calls the sharedConsumerwith the success value sent viaonSuccessfor eachMaybeObserverthat subscribes to the currentMaybe.@NonNull Maybe<T>doOnTerminate(@NonNull Action onTerminate)Returns aMaybeinstance that calls the given onTerminate callback just before thisMaybecompletes normally or with an exception.static <@NonNull T>
@NonNull Maybe<T>empty()Returns a (singleton)Maybeinstance that callsonCompleteimmediately.static <@NonNull T>
@NonNull Maybe<T>error(@NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)Returns aMaybethat invokes aMaybeObserver'sonErrormethod when theMaybeObserversubscribes to it.static <@NonNull T>
@NonNull Maybe<T>error(@NonNull java.lang.Throwable throwable)Returns aMaybethat invokes a subscriber'sonErrormethod when the subscriber subscribes to it.@NonNull Maybe<T>filter(@NonNull Predicate<? super @NonNull T> predicate)Filters the success item of theMaybevia a predicate function and emitting it if the predicate returnstrue, completing otherwise.<@NonNull R>
@NonNull Maybe<R>flatMap(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)Returns aMaybethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.<@NonNull R>
@NonNull Maybe<R>flatMap(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> onSuccessMapper, @NonNull Function<? super java.lang.Throwable,? extends MaybeSource<? extends @NonNull R>> onErrorMapper, @NonNull Supplier<? extends MaybeSource<? extends @NonNull R>> onCompleteSupplier)Maps theonSuccess,onErrororonCompletesignals of the currentMaybeinto aMaybeSourceand emits thatMaybeSource's signals.<@NonNull U,@NonNull R>
@NonNull Maybe<R>flatMap(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)Returns aMaybethat emits the results of a specified function to the pair of values emitted by the currentMaybeand a specified mappedMaybeSource.@NonNull CompletableflatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)Returns aCompletablethat completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.<@NonNull R>
@NonNull Observable<R>flatMapObservable(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)Returns anObservablethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns anObservableSource.<@NonNull R>
@NonNull Flowable<R>flatMapPublisher(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)Returns aFlowablethat emits items based on applying a specified function to the item emitted by the currentMaybe, where that function returns aPublisher.<@NonNull R>
@NonNull Maybe<R>flatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)Returns aMaybebased on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle.<@NonNull U>
@NonNull Flowable<U>flattenAsFlowable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)Maps the success value of the currentMaybeinto anIterableand emits its items as aFlowablesequence.<@NonNull U>
@NonNull Observable<U>flattenAsObservable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)Maps the success value of the currentMaybeinto anIterableand emits its items as anObservablesequence.<@NonNull R>
@NonNull Flowable<R>flattenStreamAsFlowable(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)Maps the upstream succecss value into a JavaStreamand emits its items to the downstream consumer as aFlowable.<@NonNull R>
@NonNull Observable<R>flattenStreamAsObservable(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)Maps the upstream succecss value into a JavaStreamand emits its items to the downstream consumer as anObservable.static <@NonNull T>
@NonNull Maybe<T>fromAction(@NonNull Action action)Returns aMaybeinstance that runs the givenActionfor eachMaybeObserverand emits either its exception or simply completes.static <T> @NonNull Maybe<@NonNull T>fromCallable(@NonNull java.util.concurrent.Callable<? extends @Nullable T> callable)Returns aMaybethat invokes the givenCallablefor each individualMaybeObserverthat subscribes and emits the resulting non-nullitem viaonSuccesswhile considering anullresult from theCallableas indication for valueless completion viaonComplete.static <@NonNull T>
@NonNull Maybe<T>fromCompletable(@NonNull CompletableSource completableSource)Wraps aCompletableSourceinto aMaybe.static <@NonNull T>
@NonNull Maybe<@NonNull T>fromCompletionStage(@NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)Signals the completion value or error of the given (hot)CompletionStage-based asynchronous calculation.static <@NonNull T>
@NonNull Maybe<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future)Converts aFutureinto aMaybe, treating anullresult as an indication of emptiness.static <@NonNull T>
@NonNull Maybe<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull java.util.concurrent.TimeUnit unit)Converts aFutureinto aMaybe, with a timeout on theFuture.static <@NonNull T>
@NonNull Maybe<T>fromObservable(@NonNull ObservableSource<@NonNull T> source)Wraps anObservableSourceinto aMaybeand emits the very first item or completes if the source is empty.static <@NonNull T>
@NonNull Maybe<@NonNull T>fromOptional(@NonNull java.util.Optional<@NonNull T> optional)Converts the existing value of the provided optional into ajust(Object)or an empty optional into anempty()Maybeinstance.static <@NonNull T>
@NonNull Maybe<T>fromPublisher(@NonNull org.reactivestreams.Publisher<@NonNull T> source)Wraps aPublisherinto aMaybeand emits the very first item or completes if the source is empty.static <@NonNull T>
@NonNull Maybe<T>fromRunnable(@NonNull java.lang.Runnable run)Returns aMaybeinstance that runs the givenRunnablefor eachMaybeObserverand emits either its unchecked exception or simply completes.static <@NonNull T>
@NonNull Maybe<T>fromSingle(@NonNull SingleSource<@NonNull T> single)Wraps aSingleSourceinto aMaybe.static <T> @NonNull Maybe<@NonNull T>fromSupplier(@NonNull Supplier<? extends @Nullable T> supplier)Returns aMaybethat invokes the givenSupplierfor each individualMaybeObserverthat subscribes and emits the resulting non-nullitem viaonSuccesswhile considering anullresult from theSupplieras indication for valueless completion viaonComplete.@NonNull Maybe<T>hide()Hides the identity of thisMaybeand itsDisposable.@NonNull CompletableignoreElement()Returns aCompletablethat ignores the item emitted by the currentMaybeand only callsonCompleteoronError.@NonNull Single<java.lang.Boolean>isEmpty()static <@NonNull T>
@NonNull Maybe<T>just(@NonNull T item)Returns aMaybethat emits a specified item.<@NonNull R>
@NonNull Maybe<R>lift(@NonNull MaybeOperator<? extends @NonNull R,? super @NonNull T> lift)This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aMaybewhich, when subscribed to, invokes theapply(MaybeObserver)method of the providedMaybeOperatorfor each individual downstreamMaybeand allows the insertion of a custom operator by accessing the downstream'sMaybeObserverduring this subscription phase and providing a newMaybeObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.<@NonNull R>
@NonNull Maybe<R>map(@NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)Returns aMaybethat applies a specified function to the item emitted by the currentMaybeand emits the result of this function application.<@NonNull R>
@NonNull Maybe<R>mapOptional(@NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)Maps the upstream success value into anOptionaland emits the contained item if not empty.@NonNull Single<Notification<T>>materialize()Maps the signal types of thisMaybeinto aNotificationof the same kind and emits it as aSingle'sonSuccessvalue to downstream.static <@NonNull T>
@NonNull Maybe<T>merge(@NonNull MaybeSource<? extends MaybeSource<? extends @NonNull T>> source)Flattens aMaybeSourcethat emits aMaybeSourceinto a singleMaybeSourcethat emits the item emitted by the nestedMaybeSource, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2)Flattens twoMaybeSources into a singleFlowable, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3)Flattens threeMaybeSources into a singleFlowable, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull MaybeSource<? extends @NonNull T> source4)Flattens fourMaybeSources into a singleFlowable, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Merges anIterablesequence ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Merges aPublishersequence ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Merges aPublishersequence ofMaybeSourceinstances into a singleFlowablesequence, running at most maxConcurrencyMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>mergeArray(MaybeSource<? extends @NonNull T>... sources)Merges an array ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.static <@NonNull T>
@NonNull Flowable<T>mergeArrayDelayError(@NonNull MaybeSource<? extends @NonNull T>... sources)Flattens an array ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2)Flattens twoMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3)Flattens threeMaybeSourceinto oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull MaybeSource<? extends @NonNull T> source4)Flattens fourMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)Flattens anIterablesequence ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Flattens aPublisherthat emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)Flattens aPublisherthat emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisheras well as limiting the total number of activeMaybeSources.@NonNull Flowable<T>mergeWith(@NonNull MaybeSource<? extends @NonNull T> other)static <@NonNull T>
@NonNull Maybe<T>never()Returns aMaybethat never sends any items or notifications to aMaybeObserver.@NonNull Maybe<T>observeOn(@NonNull Scheduler scheduler)Wraps aMaybeto emit its item (or notify of its error) on a specifiedScheduler, asynchronously.<@NonNull U>
@NonNull Maybe<U>ofType(@NonNull java.lang.Class<@NonNull U> clazz)Filters the items emitted by the currentMaybe, only emitting its success value if that is an instance of the suppliedClass.@NonNull Maybe<T>onErrorComplete()Returns aMaybeinstance that if thisMaybeemits an error, it will emit anonCompleteand swallow the throwable.@NonNull Maybe<T>onErrorComplete(@NonNull Predicate<? super java.lang.Throwable> predicate)Returns aMaybeinstance that if thisMaybeemits an error and the predicate returnstrue, it will emit anonCompleteand swallow the throwable.@NonNull Maybe<T>onErrorResumeNext(@NonNull Function<? super java.lang.Throwable,? extends MaybeSource<? extends @NonNull T>> fallbackSupplier)Resumes the flow with aMaybeSourcereturned for the failureThrowableof the currentMaybeby a function instead of signaling the error viaonError.@NonNull Maybe<T>onErrorResumeWith(@NonNull MaybeSource<? extends @NonNull T> fallback)Resumes the flow with the givenMaybeSourcewhen the currentMaybefails instead of signaling the error viaonError.@NonNull Maybe<T>onErrorReturn(@NonNull Function<? super java.lang.Throwable,? extends @NonNull T> itemSupplier)Ends the flow with a success item returned by a function for theThrowableerror signaled by the currentMaybeinstead of signaling the error viaonError.@NonNull Maybe<T>onErrorReturnItem(@NonNull T item)Ends the flow with the given success item when the currentMaybefails instead of signaling the error viaonError.@NonNull Maybe<T>onTerminateDetach()Nulls out references to the upstream producer and downstreamMaybeObserverif the sequence is terminated or downstream callsdispose().@NonNull Flowable<T>repeat()Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeindefinitely.@NonNull Flowable<T>repeat(long times)Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeat mostcounttimes.@NonNull Flowable<T>repeatUntil(@NonNull BooleanSupplier stop)Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeuntil the provided stop function returnstrue.@NonNull Flowable<T>repeatWhen(@NonNull Function<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)Returns aFlowablethat emits the same values as the currentMaybewith the exception of anonComplete.@NonNull Maybe<T>retry()Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonError(infinite retry count).@NonNull Maybe<T>retry(long times)Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonErrorup to a specified number of retries.@NonNull Maybe<T>retry(long times, @NonNull Predicate<? super java.lang.Throwable> predicate)Retries at mosttimesor until the predicate returnsfalse, whichever happens first.@NonNull Maybe<T>retry(@NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonErrorand the predicate returnstruefor that specific exception and retry count.@NonNull Maybe<T>retry(@NonNull Predicate<? super java.lang.Throwable> predicate)Retries the currentMaybeif it fails and the predicate returnstrue.@NonNull Maybe<T>retryUntil(@NonNull BooleanSupplier stop)Retries until the given stop function returnstrue.@NonNull Maybe<T>retryWhen(@NonNull Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)Returns aMaybethat emits the same values as the currentMaybewith the exception of anonError.voidsafeSubscribe(@NonNull MaybeObserver<? super @NonNull T> observer)Wraps the givenMaybeObserver, catches anyRuntimeExceptions thrown by itsMaybeObserver.onSubscribe(Disposable),MaybeObserver.onSuccess(Object),MaybeObserver.onError(Throwable)orMaybeObserver.onComplete()methods and routes those to the global error handler viaRxJavaPlugins.onError(Throwable).static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2)Returns aSinglethat emits aBooleanvalue that indicates whether twoMaybeSourcesequences are the same by comparing the items emitted by eachMaybeSourcepairwise.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull MaybeSource<? extends @NonNull T> source1, @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)Returns aSinglethat emits aBooleanvalue that indicates whether twoMaybeSources are the same by comparing the items emitted by eachMaybeSourcepairwise based on the results of a specified equality function.@NonNull Flowable<T>startWith(@NonNull CompletableSource other)Returns aFlowablewhich first runs the otherCompletableSourcethen the currentMaybeif the other completed normally.@NonNull Flowable<T>startWith(@NonNull MaybeSource<@NonNull T> other)Returns aFlowablewhich first runs the otherMaybeSourcethen the currentMaybeif the other succeeded or completed normally.@NonNull Observable<T>startWith(@NonNull ObservableSource<@NonNull T> other)Returns anObservablewhich first delivers the events of the otherObservableSourcethen runs the currentMaybe.@NonNull Flowable<T>startWith(@NonNull SingleSource<@NonNull T> other)Returns aFlowablewhich first runs the otherSingleSourcethen the currentMaybeif the other succeeded normally.@NonNull Flowable<T>startWith(@NonNull org.reactivestreams.Publisher<@NonNull T> other)Returns aFlowablewhich first delivers the events of the otherPublisherthen runs the currentMaybe.@NonNull Disposablesubscribe()Subscribes to aMaybeand ignoresonSuccessandonCompleteemissions.voidsubscribe(@NonNull MaybeObserver<? super @NonNull T> observer)Subscribes the givenMaybeObserverto thisMaybeSourceinstance.@NonNull Disposablesubscribe(@NonNull Consumer<? super @NonNull T> onSuccess)Subscribes to aMaybeand provides a callback to handle the items it emits.@NonNull Disposablesubscribe(@NonNull Consumer<? super @NonNull T> onSuccess, @NonNull Consumer<? super java.lang.Throwable> onError)Subscribes to aMaybeand provides callbacks to handle the items it emits and any error notification it issues.@NonNull Disposablesubscribe(@NonNull Consumer<? super @NonNull T> onSuccess, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)Subscribes to aMaybeand provides callbacks to handle the items it emits and any error or completion notification it issues.@NonNull Disposablesubscribe(@NonNull Consumer<? super @NonNull T> onSuccess, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete, @NonNull DisposableContainer container)Wraps the given onXXX callbacks into aDisposableMaybeObserver, adds it to the givenDisposableContainerand ensures, that if the upstream terminates or this particularDisposableis disposed, theMaybeObserveris removed from the given composite.protected abstract voidsubscribeActual(@NonNull MaybeObserver<? super @NonNull T> observer)Implement this method in subclasses to handle the incomingMaybeObservers.@NonNull Maybe<T>subscribeOn(@NonNull Scheduler scheduler)Asynchronously subscribes subscribers to thisMaybeon the specifiedScheduler.<@NonNull E extends MaybeObserver<? super @NonNull T>>
EsubscribeWith(@NonNull E observer)Subscribes a givenMaybeObserver(subclass) to thisMaybeand returns the givenMaybeObserveras is.@NonNull Maybe<T>switchIfEmpty(@NonNull MaybeSource<? extends @NonNull T> other)Returns aMaybethat emits the items emitted by the currentMaybeor the items of an alternateMaybeSourceif the currentMaybeis empty.@NonNull Single<T>switchIfEmpty(@NonNull SingleSource<? extends @NonNull T> other)Returns aSinglethat emits the items emitted by the currentMaybeor the item of an alternateSingleSourceif the currentMaybeis empty.static <@NonNull T>
@NonNull Flowable<T>switchOnNext(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Switches betweenMaybeSources emitted by the sourcePublisherwhenever a newMaybeSourceis emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowablesequence.static <@NonNull T>
@NonNull Flowable<T>switchOnNextDelayError(@NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)Switches betweenMaybeSources emitted by the sourcePublisherwhenever a newMaybeSourceis emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowablesequence and delaying all errors from all of them until all terminate.<@NonNull U>
@NonNull Maybe<T>takeUntil(@NonNull MaybeSource<@NonNull U> other)Returns aMaybethat emits the items emitted by the currentMaybeuntil a secondMaybeSourceemits an item.<@NonNull U>
@NonNull Maybe<T>takeUntil(@NonNull org.reactivestreams.Publisher<@NonNull U> other)Returns aMaybethat emits the item emitted by the currentMaybeuntil a secondPublisheremits an item.@NonNull TestObserver<T>test()Creates aTestObserverand subscribes it to thisMaybe.@NonNull TestObserver<T>test(boolean dispose)Creates aTestObserveroptionally in cancelled state, then subscribes it to thisMaybe.@NonNull Maybe<Timed<T>>timeInterval()Measures the time (in milliseconds) between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.@NonNull Maybe<Timed<T>>timeInterval(@NonNull Scheduler scheduler)Measures the time (in milliseconds) between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.@NonNull Maybe<Timed<T>>timeInterval(@NonNull java.util.concurrent.TimeUnit unit)Measures the time between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.@NonNull Maybe<Timed<T>>timeInterval(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)Measures the time between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.@NonNull Maybe<T>timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit)Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item.@NonNull Maybe<T>timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull MaybeSource<? extends @NonNull T> fallback)Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item.@NonNull Maybe<T>timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler.@NonNull Maybe<T>timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull MaybeSource<? extends @NonNull T> fallback)Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item using a specifiedScheduler.<@NonNull U>
@NonNull Maybe<T>timeout(@NonNull MaybeSource<@NonNull U> timeoutIndicator)If the currentMaybedidn't signal an event before thetimeoutIndicatorMaybeSourcesignals, aTimeoutExceptionis signaled instead.<@NonNull U>
@NonNull Maybe<T>timeout(@NonNull MaybeSource<@NonNull U> timeoutIndicator, @NonNull MaybeSource<? extends @NonNull T> fallback)If the currentMaybedidn't signal an event before thetimeoutIndicatorMaybeSourcesignals, the currentMaybeis disposed and thefallbackMaybeSourcesubscribed to as a continuation.<@NonNull U>
@NonNull Maybe<T>timeout(@NonNull org.reactivestreams.Publisher<@NonNull U> timeoutIndicator)If the currentMaybesource didn't signal an event before thetimeoutIndicatorPublishersignals, aTimeoutExceptionis signaled instead.<@NonNull U>
@NonNull Maybe<T>timeout(@NonNull org.reactivestreams.Publisher<@NonNull U> timeoutIndicator, @NonNull MaybeSource<? extends @NonNull T> fallback)If the currentMaybedidn't signal an event before thetimeoutIndicatorPublishersignals, the currentMaybeis disposed and thefallbackMaybeSourcesubscribed to as a continuation.static @NonNull Maybe<java.lang.Long>timer(long delay, @NonNull java.util.concurrent.TimeUnit unit)Returns aMaybethat emits0Lafter a specified delay.static @NonNull Maybe<java.lang.Long>timer(long delay, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)@NonNull Maybe<Timed<T>>timestamp()@NonNull Maybe<Timed<T>>timestamp(@NonNull Scheduler scheduler)@NonNull Maybe<Timed<T>>timestamp(@NonNull java.util.concurrent.TimeUnit unit)@NonNull Maybe<Timed<T>>timestamp(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)<R> Rto(@NonNull MaybeConverter<@NonNull T,? extends R> converter)Calls the specified converter function during assembly time and returns its resulting value.@NonNull java.util.concurrent.CompletionStage<T>toCompletionStage()Signals the upstream success item (or aNoSuchElementExceptionif the upstream is empty) via aCompletionStage.@NonNull java.util.concurrent.CompletionStage<T>toCompletionStage(@NonNull T defaultItem)Signals the upstream success item (or the default item if the upstream is empty) via aCompletionStage.@NonNull Flowable<T>toFlowable()Converts thisMaybeinto a backpressure-awareFlowableinstance composing cancellation through.@NonNull java.util.concurrent.Future<T>toFuture()Returns aFuturerepresenting the single value emitted by the currentMaybeornullif the currentMaybeis empty.@NonNull Observable<T>toObservable()Converts thisMaybeinto anObservableinstance composing disposal through.@NonNull Single<T>toSingle()Converts thisMaybeinto aSingleinstance composing disposal through and turning an emptyMaybeinto a signal ofNoSuchElementException.static <@NonNull T>
@NonNull Maybe<T>unsafeCreate(@NonNull MaybeSource<@NonNull T> onSubscribe)Advanced use only: creates aMaybeinstance without any safeguards by using a callback that is called with aMaybeObserver.@NonNull Maybe<T>unsubscribeOn(@NonNull Scheduler scheduler)Returns aMaybewhich makes sure when aMaybeObserverdisposes theDisposable, that call is propagated up on the specifiedScheduler.static <@NonNull T,@NonNull D>
@NonNull Maybe<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends MaybeSource<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup)Constructs aMaybethat creates a dependent resource object which is disposed of when the generatedMaybeSourceterminates or the downstream calls dispose().static <@NonNull T,@NonNull D>
@NonNull Maybe<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends MaybeSource<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)Constructs aMaybethat creates a dependent resource object which is disposed first ({code eager == true}) when the generatedMaybeSourceterminates or the downstream disposes; or after ({code eager == false}).static <@NonNull T>
@NonNull Maybe<T>wrap(@NonNull MaybeSource<@NonNull T> source)static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull MaybeSource<? extends @NonNull T8> source8, @NonNull MaybeSource<? extends @NonNull T9> source9, @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull MaybeSource<? extends @NonNull T8> source8, @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherMaybeSources.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Maybe<R>zip(@NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherMaybeSources.static <@NonNull T,@NonNull R>
@NonNull Maybe<R>zip(@NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)Returns aMaybethat emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterableof otherMaybeSources.static <@NonNull T,@NonNull R>
@NonNull Maybe<R>zipArray(@NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, @NonNull MaybeSource<? extends @NonNull T>... sources)Returns aMaybethat emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherMaybeSources.<@NonNull U,@NonNull R>
@NonNull Maybe<R>zipWith(@NonNull MaybeSource<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)Waits until this and the otherMaybeSourcesignal a success value then applies the givenBiFunctionto those values and emits theBiFunction's resulting value to downstream.
-
-
-
Method Detail
-
amb
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> amb(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Runs multipleMaybeSources provided by anIterablesequence and signals the events of the first one that signals (disposing the rest).
- Scheduler:
ambdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- theIterablesequence of sources. A subscription to each source will occur in the same order as in theIterable.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
ambArray
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Maybe<T> ambArray(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Runs multipleMaybeSources and signals the events of the first one that signals (disposing the rest).
- Scheduler:
ambArraydoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- the array of sources. A subscription to each source will occur in the same order as in the array.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by anIterablesequence as aFlowablesequence.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- theIterablesequence ofMaybeSourceinstances- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2)
Returns aFlowablethat emits the items emitted by twoMaybeSources, one after the other.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be concatenatedsource2- aMaybeSourceto be concatenated- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1orsource2isnull- See Also:
- ReactiveX operators documentation: Concat
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3)
Returns aFlowablethat emits the items emitted by threeMaybeSources, one after the other.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be concatenatedsource2- aMaybeSourceto be concatenatedsource3- aMaybeSourceto be concatenated- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2orsource3isnull- See Also:
- ReactiveX operators documentation: Concat
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T> source4)
Returns aFlowablethat emits the items emitted by fourMaybeSources, one after the other.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be concatenatedsource2- aMaybeSourceto be concatenatedsource3- aMaybeSourceto be concatenatedsource4- aMaybeSourceto be concatenated- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3orsource4isnull- See Also:
- ReactiveX operators documentation: Concat
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by aPublishersequence as aFlowablesequence.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer and expects thePublisherto honor backpressure as well. If the sourcesPublisherviolates this, aMissingBackpressureExceptionis signaled. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- thePublisherofMaybeSourceinstances- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concat
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int prefetch)
Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources provided by aPublishersequence as aFlowablesequence.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer and expects thePublisherto honor backpressure as well. If the sourcesPublisherviolates this, aMissingBackpressureExceptionis signaled. - Scheduler:
concatdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- thePublisherofMaybeSourceinstancesprefetch- the number ofMaybeSources to prefetch from thePublisher- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifprefetchis non-positive
-
concatArray
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> concatArray(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Concatenate the single values, in a non-overlapping fashion, of theMaybeSourcesources in the array as aFlowablesequence.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
concatArraydoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
sources- the array ofMaybeSourceinstances- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatArrayDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArrayDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Concatenates a variable number ofMaybeSourcesources and delays errors from any of them till all terminate as aFlowablesequence.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
concatArrayDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common base value type- Parameters:
sources- the array of sources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatArrayEager
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> concatArrayEager(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Concatenates a sequence ofMaybeSourceeagerly into aFlowablesequence.Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the value emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatArrayEagerDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> concatArrayEagerDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Concatenates a sequence ofMaybeSourceeagerly into aFlowablesequence.Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the value emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull- Since:
- 3.0.0
-
concatDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates theIterablesequence ofMaybeSources into a single sequence by subscribing to eachMaybeSource, one after the other, one at a time and delays any errors till the all innerMaybeSources terminate as aFlowablesequence.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
concatDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- theIterablesequence ofMaybeSources- Returns:
- the new
Flowablewith the concatenating behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates thePublishersequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisherterminate as aFlowablesequence.
- Backpressure:
concatDelayErrorfully supports backpressure.- Scheduler:
concatDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- thePublishersequence ofMaybeSources- Returns:
- the new
Flowablewith the concatenating behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int prefetch)
Concatenates thePublishersequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisherterminate as aFlowablesequence.
- Backpressure:
concatDelayErrorfully supports backpressure.- Scheduler:
concatDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- thePublishersequence ofMaybeSourcesprefetch- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSourceterminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSources.- Returns:
- the new
Flowablewith the concatenating behavior - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifprefetchis non-positive- Since:
- 3.0.0
-
concatEager
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the values emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSourcethat need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatEager
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence and runs a limited number of the inner sequences at once.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the values emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSourcethat need to be eagerly concatenatedmaxConcurrency- the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUEis interpreted as all innerMaybeSources can be active at the same time- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- Since:
- 3.0.0
-
concatEager
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
MaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.
- Backpressure:
- Backpressure is honored towards the downstream and the outer
Publisheris expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException. - Scheduler:
- This method does not operate by default on a particular
Scheduler.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull
-
concatEager
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, running at most the given number of innerMaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
MaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and the outer
Publisheris expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException. - Scheduler:
- This method does not operate by default on a particular
Scheduler.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenatedmaxConcurrency- the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUEis interpreted as all innerMaybeSources can be active at the same time- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- Since:
- 3.0.0
-
concatEagerDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all innerMaybeSources terminate.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the values emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSourcethat need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull- Since:
- 3.0.0
-
concatEagerDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Concatenates a sequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all innerMaybeSources terminate and runs a limited number of innerMaybeSources at once.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the source
MaybeSources. The operator buffers the values emitted by theseMaybeSources 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.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSourcethat need to be eagerly concatenatedmaxConcurrency- the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUEis interpreted as all innerMaybeSources can be active at the same time- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- Since:
- 3.0.0
-
concatEagerDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all the inner and the outer sequence terminate.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
MaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and the outer
Publisheris expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException. - Scheduler:
- This method does not operate by default on a particular
Scheduler.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenated- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnull- Since:
- 3.0.0
-
concatEagerDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Concatenates aPublishersequence ofMaybeSources eagerly into aFlowablesequence, delaying errors until all the inner and the outer sequence terminate and runs a limited number of the innerMaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
MaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and the outer
Publisheris expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException. - Scheduler:
- This method does not operate by default on a particular
Scheduler.
- Type Parameters:
T- the value type- Parameters:
sources- a sequence ofMaybeSources that need to be eagerly concatenatedmaxConcurrency- the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUEis interpreted as all innerMaybeSources can be active at the same time- Returns:
- the new
Flowableinstance with the specified concatenation behavior - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- Since:
- 3.0.0
-
create
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> create(@NonNull @NonNull MaybeOnSubscribe<@NonNull T> onSubscribe)
Provides an API (via a coldMaybe) 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); });Whenever a
MaybeObserversubscribes to the returnedMaybe, the providedMaybeOnSubscribecallback is invoked with a fresh instance of aMaybeEmitterthat will interact only with that specificMaybeObserver. If thisMaybeObserverdisposes the flow (makingMaybeEmitter.isDisposed()returntrue), other observers subscribed to the same returnedMaybeare not affected.- Scheduler:
createdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
onSubscribe- the emitter that is called when aMaybeObserversubscribes to the returnedMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonSubscribeisnull- See Also:
MaybeOnSubscribe,Cancellable
-
defer
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> defer(@NonNull @NonNull Supplier<? extends @NonNull MaybeSource<? extends @NonNull T>> supplier)
Calls aSupplierfor each individualMaybeObserverto return the actualMaybeSourcesource to be subscribed to.
- Scheduler:
deferdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
supplier- theSupplierthat is called for each individualMaybeObserverand returns aMaybeSourceinstance to subscribe to- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsupplierisnull
-
empty
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Maybe<T> empty()
Returns a (singleton)Maybeinstance that callsonCompleteimmediately.
- Scheduler:
emptydoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Returns:
- the shared
Maybeinstance
-
error
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> error(@NonNull @NonNull java.lang.Throwable throwable)
Returns aMaybethat invokes a subscriber'sonErrormethod when the subscriber subscribes to it.
- Scheduler:
errordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of the item (ostensibly) emitted by theMaybe- Parameters:
throwable- the particularThrowableto pass toonError- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifthrowableisnull- See Also:
- ReactiveX operators documentation: Throw
-
error
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> error(@NonNull @NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)
Returns aMaybethat invokes aMaybeObserver'sonErrormethod when theMaybeObserversubscribes to it.
- Scheduler:
errordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of the items (ostensibly) emitted by theMaybe- Parameters:
supplier- aSupplierfactory to return aThrowablefor each individualMaybeObserver- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsupplierisnull- See Also:
- ReactiveX operators documentation: Throw
-
fromAction
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromAction(@NonNull @NonNull Action action)
Returns aMaybeinstance that runs the givenActionfor eachMaybeObserverand emits either its exception or simply completes.
- Scheduler:
fromActiondoes not operate by default on a particularScheduler.- Error handling:
- If the
Actionthrows an exception, the respectiveThrowableis delivered to the downstream viaMaybeObserver.onError(Throwable), except when the downstream has disposed the resultingMaybesource. In this latter case, theThrowableis delivered to the global error handler viaRxJavaPlugins.onError(Throwable)as anUndeliverableException.
- Type Parameters:
T- the target type- Parameters:
action- theActionto run for eachMaybeObserver- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifactionisnull
-
fromCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromCompletable(@NonNull @NonNull CompletableSource completableSource)
Wraps aCompletableSourceinto aMaybe.
- Scheduler:
fromCompletabledoes not operate by default on a particularScheduler.
- Type Parameters:
T- the target type- Parameters:
completableSource- theCompletableSourceto convert from- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifcompletableSourceisnull
-
fromSingle
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromSingle(@NonNull @NonNull SingleSource<@NonNull T> single)
Wraps aSingleSourceinto aMaybe.
- Scheduler:
fromSingledoes not operate by default on a particularScheduler.
- Type Parameters:
T- the target type- Parameters:
single- theSingleSourceto convert from- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsingleisnull
-
fromCallable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <T> @NonNull Maybe<@NonNull T> fromCallable(@NonNull @NonNull java.util.concurrent.Callable<? extends @Nullable T> callable)
Returns aMaybethat invokes the givenCallablefor each individualMaybeObserverthat subscribes and emits the resulting non-nullitem viaonSuccesswhile considering anullresult from theCallableas indication for valueless completion viaonComplete.
This operator allows you to defer the execution of the given
Callableuntil aMaybeObserversubscribes to the returnedMaybe. In other terms, this source operator evaluates the givenCallable"lazily".Note that the
nullhandling of this operator differs from the similar source operators in the otherbase reactive classes. Those operators signal aNullPointerExceptionif the value returned by theirCallableisnullwhile thisfromCallableconsiders it to indicate the returnedMaybeis empty.- Scheduler:
fromCallabledoes not operate by default on a particularScheduler.- Error handling:
- Any non-fatal exception thrown by
Callable.call()will be forwarded toonError, except if theMaybeObserverdisposed the subscription in the meantime. In this latter case, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)wrapped into aUndeliverableException. Fatal exceptions are rethrown and usually will end up in the executing thread'sThread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable)handler.
- Type Parameters:
T- the type of the item emitted by theMaybe.- Parameters:
callable- aCallableinstance whose execution should be deferred and performed for each individualMaybeObserverthat subscribes to the returnedMaybe.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifcallableisnull- See Also:
defer(Supplier),fromSupplier(Supplier)
-
fromFuture
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future)
Converts aFutureinto aMaybe, treating anullresult as an indication of emptiness.
The operator calls
Future.get(), which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)to move this blocking wait to a background thread, and if theSchedulersupports it, interrupt the wait when the flow is disposed.Unlike 1.x, disposing the
Maybewon't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futureMaybe.doOnDispose(() -> future.cancel(true));.- Scheduler:
fromFuturedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resultingMaybe- Parameters:
future- the sourceFuture- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iffutureisnull- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromFuture
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Converts aFutureinto aMaybe, with a timeout on theFuture.
The operator calls
Future.get(long, TimeUnit), which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)to move this blocking wait to a background thread, and if theSchedulersupports it, interrupt the wait when the flow is disposed.Unlike 1.x, disposing the
Maybewon't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futureMaybe.doOnCancel(() -> future.cancel(true));.- Scheduler:
fromFuturedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of object that theFuturereturns, and also the type of item to be emitted by the resultingMaybe- Parameters:
future- the sourceFuturetimeout- the maximum time to wait before callinggetunit- theTimeUnitof thetimeoutargument- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iffutureorunitisnull- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromObservable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromObservable(@NonNull @NonNull ObservableSource<@NonNull T> source)
Wraps anObservableSourceinto aMaybeand emits the very first item or completes if the source is empty.
- Scheduler:
fromObservabledoes not operate by default on a particularScheduler.
- Type Parameters:
T- the target type- Parameters:
source- theObservableSourceto convert from- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourceisnull- Since:
- 3.0.0
-
fromPublisher
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(UNBOUNDED_IN) public static <@NonNull T> @NonNull Maybe<T> fromPublisher(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T> source)
Wraps aPublisherinto aMaybeand emits the very first item or completes if the source is empty.
- Backpressure:
- The operator consumes the given
Publisherin an unbounded manner (requestingLong.MAX_VALUE) but cancels it after one item received. - Scheduler:
fromPublisherdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the target type- Parameters:
source- thePublisherto convert from- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourceisnull- Since:
- 3.0.0
-
fromRunnable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> fromRunnable(@NonNull @NonNull java.lang.Runnable run)
Returns aMaybeinstance that runs the givenRunnablefor eachMaybeObserverand emits either its unchecked exception or simply completes.
If the code to be wrapped needs to throw a checked or more broader
Throwableexception, that exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively, use thefromAction(Action)method which allows the wrapped code to throw anyThrowableexception and will signal it to observers as-is.- Scheduler:
fromRunnabledoes not operate by default on a particularScheduler.- Error handling:
- If the
Runnablethrows an exception, the respectiveThrowableis delivered to the downstream viaMaybeObserver.onError(Throwable), except when the downstream has disposed thisMaybesource. In this latter case, theThrowableis delivered to the global error handler viaRxJavaPlugins.onError(Throwable)as anUndeliverableException.
- Type Parameters:
T- the target type- Parameters:
run- theRunnableto run for eachMaybeObserver- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifrunisnull- See Also:
fromAction(Action)
-
fromSupplier
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <T> @NonNull Maybe<@NonNull T> fromSupplier(@NonNull @NonNull Supplier<? extends @Nullable T> supplier)
Returns aMaybethat invokes the givenSupplierfor each individualMaybeObserverthat subscribes and emits the resulting non-nullitem viaonSuccesswhile considering anullresult from theSupplieras indication for valueless completion viaonComplete.This operator allows you to defer the execution of the given
Supplieruntil aMaybeObserversubscribes to the returnedMaybe. In other terms, this source operator evaluates the givenSupplier"lazily".
Note that the
nullhandling of this operator differs from the similar source operators in the otherbase reactive classes. Those operators signal aNullPointerExceptionif the value returned by theirSupplierisnullwhile thisfromSupplierconsiders it to indicate the returnedMaybeis empty.- Scheduler:
fromSupplierdoes not operate by default on a particularScheduler.- Error handling:
- Any non-fatal exception thrown by
Supplier.get()will be forwarded toonError, except if theMaybeObserverdisposed the subscription in the meantime. In this latter case, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)wrapped into aUndeliverableException. Fatal exceptions are rethrown and usually will end up in the executing thread'sThread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable)handler.
- Type Parameters:
T- the type of the item emitted by theMaybe.- Parameters:
supplier- aSupplierinstance whose execution should be deferred and performed for each individualMaybeObserverthat subscribes to the returnedMaybe.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsupplierisnull- Since:
- 3.0.0
- See Also:
defer(Supplier),fromCallable(Callable)
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> just(@NonNull T item)
Returns aMaybethat emits a specified item.
To convert any object into a
Maybethat emits that object, pass that object into thejustmethod.- Scheduler:
justdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of that item- Parameters:
item- the item to emit- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifitemisnull- See Also:
- ReactiveX operators documentation: Just
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Merges anIterablesequence ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common and resulting value type- Parameters:
sources- theIterablesequence ofMaybeSourcesources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
mergeDelayError(Iterable)
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Merges aPublishersequence ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common and resulting value type- Parameters:
sources- theFlowablesequence ofMaybeSourcesources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
mergeDelayError(Publisher)
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Merges aPublishersequence ofMaybeSourceinstances into a singleFlowablesequence, running at most maxConcurrencyMaybeSources at once.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, int)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common and resulting value type- Parameters:
sources- theFlowablesequence ofMaybeSourcesourcesmaxConcurrency- the maximum number of concurrently runningMaybeSources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- See Also:
mergeDelayError(Publisher, int)
-
merge
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> merge(@NonNull @NonNull MaybeSource<? extends MaybeSource<? extends @NonNull T>> source)
Flattens aMaybeSourcethat emits aMaybeSourceinto a singleMaybeSourcethat emits the item emitted by the nestedMaybeSource, without any transformation.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- The resulting
Maybeemits the outer source's or the innerMaybeSource'sThrowableas is. Unlike the othermerge()operators, this operator won't and can't produce aCompositeExceptionbecause there is only one possibility for the outer or the innerMaybeSourceto emit anonErrorsignal. Therefore, there is no need for amergeDelayError(MaybeSource<MaybeSource<T>>)operator.
- Type Parameters:
T- the value type of the sources and the output- Parameters:
source- aMaybeSourcethat emits aMaybeSource- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourceisnull- See Also:
- ReactiveX operators documentation: Merge
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2)
Flattens twoMaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multiple
MaybeSources so that they appear as a singleFlowable, by using themergemethod.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1orsource2isnull- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(MaybeSource, MaybeSource)
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3)
Flattens threeMaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multiple
MaybeSources so that they appear as a singleFlowable, by using themergemethod.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource, MaybeSource)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be mergedsource3- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2orsource3isnull- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(MaybeSource, MaybeSource, MaybeSource)
-
merge
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T> source4)
Flattens fourMaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multiple
MaybeSources so that they appear as a singleFlowable, by using themergemethod.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergedoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common value type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be mergedsource3- aMaybeSourceto be mergedsource4- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3orsource4isnull- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource)
-
mergeArray
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> mergeArray(MaybeSource<? extends @NonNull T>... sources)
Merges an array ofMaybeSourceinstances into a singleFlowablesequence, running allMaybeSources at once.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeArraydoes not operate by default on a particularScheduler.- Error handling:
- If any of the source
MaybeSources signal aThrowableviaonError, the resultingFlowableterminates with thatThrowableand all other sourceMaybeSources are disposed. If more than oneMaybeSourcesignals an error, the resultingFlowablemay terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeExceptioncontaining two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)method asUndeliverableExceptionerrors. Similarly,Throwables signaled by source(s) after the returnedFlowablehas been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(MaybeSource...)to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.
- Type Parameters:
T- the common and resulting value type- Parameters:
sources- the array sequence ofMaybeSourcesources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
mergeArrayDelayError(MaybeSource...)
-
mergeArrayDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeArrayDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Flattens an array ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves like
merge(Publisher)except that if any of the mergedMaybeSources notify of an error viaonError,mergeArrayDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.Even if multiple merged
MaybeSources sendonErrornotifications,mergeArrayDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeArrayDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- the array ofMaybeSources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources)
Flattens anIterablesequence ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves like
merge(Publisher)except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.
Even if multiple merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- theIterableofMaybeSources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Flattens aPublisherthat emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher.
This behaves like
merge(Publisher)except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources and the mainPublisherhave finished emitting items.Even if multiple merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisheris consumed in unbounded mode (i.e., no backpressure is applied to it). - Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
sources- aPublisherthat emitsMaybeSources- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens aPublisherthat emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisheras well as limiting the total number of activeMaybeSources.
This behaves like
merge(Publisher, int)except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources and the mainPublisherhave finished emitting items.Even if multiple merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisheris consumed in unbounded mode (i.e., no backpressure is applied to it). - Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
History: 2.1.9 - experimental
- Type Parameters:
T- the common element base type- Parameters:
sources- aPublisherthat emitsMaybeSourcesmaxConcurrency- the maximum number of active innerMaybeSources to be merged at a time- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnulljava.lang.IllegalArgumentException- ifmaxConcurrencyis non-positive- Since:
- 2.2
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2)
Flattens twoMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves like
merge(MaybeSource, MaybeSource)except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.Even if both merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1orsource2isnull- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3)
Flattens threeMaybeSourceinto oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves like
merge(MaybeSource, MaybeSource, MaybeSource)except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.Even if multiple merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be mergedsource3- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2orsource3isnull- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T> source4)
Flattens fourMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources 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 mergedMaybeSources notify of an error viaonError,mergeDelayErrorwill refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.Even if multiple merged
MaybeSources sendonErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its subscribers once.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeDelayErrordoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element base type- Parameters:
source1- aMaybeSourceto be mergedsource2- aMaybeSourceto be mergedsource3- aMaybeSourceto be mergedsource4- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3orsource4isnull- See Also:
- ReactiveX operators documentation: Merge
-
never
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Maybe<T> never()
Returns aMaybethat never sends any items or notifications to aMaybeObserver.
This
Maybeis useful primarily for testing purposes.- Scheduler:
neverdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of items (not) emitted by theMaybe- Returns:
- the shared
Maybeinstance - See Also:
- ReactiveX operators documentation: Never
-
sequenceEqual
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2)
Returns aSinglethat emits aBooleanvalue that indicates whether twoMaybeSourcesequences are the same by comparing the items emitted by eachMaybeSourcepairwise.
- Scheduler:
sequenceEqualdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of items emitted by eachMaybeSource- Parameters:
source1- the firstMaybeSourceto comparesource2- the secondMaybeSourceto compare- Returns:
- the new
Singleinstance - Throws:
java.lang.NullPointerException- ifsource1orsource2isnull- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull MaybeSource<? extends @NonNull T> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T> source2, @NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)
Returns aSinglethat emits aBooleanvalue that indicates whether twoMaybeSources are the same by comparing the items emitted by eachMaybeSourcepairwise based on the results of a specified equality function.
- Scheduler:
sequenceEqualdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the type of items emitted by eachMaybeSource- Parameters:
source1- the firstMaybeSourceto comparesource2- the secondMaybeSourceto compareisEqual- a function used to compare items emitted by eachMaybeSource- Returns:
- the new
Singleinstance - Throws:
java.lang.NullPointerException- ifsource1,source2orisEqualisnull- See Also:
- ReactiveX operators documentation: SequenceEqual
-
switchOnNext
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> switchOnNext(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Switches betweenMaybeSources emitted by the sourcePublisherwhenever a newMaybeSourceis emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowablesequence.
- Backpressure:
- The
sourcesPublisheris consumed in an unbounded manner (requestingLong.MAX_VALUE). The returnedFlowablerespects the backpressure from the downstream. - Scheduler:
switchOnNextdoes not operate by default on a particularScheduler.- Error handling:
- The returned sequence fails with the first error signaled by the
sourcesPublisheror the currently runningMaybeSource, disposing the rest. Late errors are forwarded to the global error handler viaRxJavaPlugins.onError(Throwable).
- Type Parameters:
T- the element type of theMaybeSources- Parameters:
sources- thePublishersequence of innerMaybeSources to switch between- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- Since:
- 3.0.0
- See Also:
switchOnNextDelayError(Publisher), ReactiveX operators documentation: Switch
-
switchOnNextDelayError
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> switchOnNextDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends MaybeSource<? extends @NonNull T>> sources)
Switches betweenMaybeSources emitted by the sourcePublisherwhenever a newMaybeSourceis emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowablesequence and delaying all errors from all of them until all terminate.
- Backpressure:
- The
sourcesPublisheris consumed in an unbounded manner (requestingLong.MAX_VALUE). The returnedFlowablerespects the backpressure from the downstream. - Scheduler:
switchOnNextDelayErrordoes not operate by default on a particularScheduler.- Error handling:
- The returned
Flowablecollects all errors emitted by either thesourcesPublisheror any innerMaybeSourceand emits them as aCompositeExceptionwhen all sources terminate. If only one source ever failed, its error is emitted as-is at the end.
- Type Parameters:
T- the element type of theMaybeSources- Parameters:
sources- thePublishersequence of innerMaybeSources to switch between- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifsourcesisnull- Since:
- 3.0.0
- See Also:
switchOnNext(Publisher), ReactiveX operators documentation: Switch
-
timer
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Maybe<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aMaybethat emits0Lafter a specified delay.
- Scheduler:
timeroperates by default on thecomputationScheduler.
- Parameters:
delay- the initial delay before emitting a single0Lunit- time units to use fordelay- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- See Also:
- ReactiveX operators documentation: Timer
-
timer
@CheckReturnValue @NonNull @SchedulerSupport("custom") public static @NonNull Maybe<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aMaybethat emits0Lafter a specified delay on a specifiedScheduler.
- Scheduler:
- You specify which
Schedulerthis operator will use.
- Parameters:
delay- the initial delay before emitting a single 0Lunit- time units to use fordelayscheduler- theSchedulerto use for scheduling the item- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- See Also:
- ReactiveX operators documentation: Timer
-
unsafeCreate
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> unsafeCreate(@NonNull @NonNull MaybeSource<@NonNull T> onSubscribe)
Advanced use only: creates aMaybeinstance without any safeguards by using a callback that is called with aMaybeObserver.
- Scheduler:
unsafeCreatedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
onSubscribe- the function that is called with the subscribingMaybeObserver- Returns:
- the new
Maybeinstance - Throws:
java.lang.IllegalArgumentException- ifonSubscribeis aMaybejava.lang.NullPointerException- ifonSubscribeisnull
-
using
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull D> @NonNull Maybe<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends MaybeSource<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup)
Constructs aMaybethat creates a dependent resource object which is disposed of when the generatedMaybeSourceterminates or the downstream calls dispose().
- Scheduler:
usingdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the element type of the generatedMaybeSourceD- the type of the resource associated with the output sequence- Parameters:
resourceSupplier- the factory function to create a resource object that depends on theMaybesourceSupplier- the factory function to create aMaybeSourceresourceCleanup- the function that will dispose of the resource- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifresourceSupplier,sourceSupplierorresourceCleanupisnull- See Also:
- ReactiveX operators documentation: Using
-
using
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull D> @NonNull Maybe<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends MaybeSource<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)
Constructs aMaybethat creates a dependent resource object which is disposed first ({code eager == true}) when the generatedMaybeSourceterminates or the downstream disposes; or after ({code eager == false}).
Eager disposal is particularly appropriate for a synchronous
Maybethat reuses resources.disposeActionwill only be called once per subscription.- Scheduler:
usingdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the element type of the generatedMaybeSourceD- the type of the resource associated with the output sequence- Parameters:
resourceSupplier- the factory function to create a resource object that depends on theMaybesourceSupplier- the factory function to create aMaybeSourceresourceCleanup- the function that will dispose of the resourceeager- Iftruethen resource disposal will happen either on adispose()call before the upstream is disposed or just before the emission of a terminal event (onSuccess,onCompleteoronError). Iffalsethe resource disposal will happen either on adispose()call after the upstream is disposed or just after the emission of a terminal event (onSuccess,onCompleteoronError).- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifresourceSupplier,sourceSupplierorresourceCleanupisnull- See Also:
- ReactiveX operators documentation: Using
-
wrap
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Maybe<T> wrap(@NonNull @NonNull MaybeSource<@NonNull T> source)
Wraps aMaybeSourceinstance into a newMaybeinstance if not already aMaybeinstance.
- Scheduler:
wrapdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the value type- Parameters:
source- the source to wrap- Returns:
- the new wrapped or cast
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourceisnull
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull java.lang.Iterable<? extends MaybeSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterableof otherMaybeSources.
Note on method signature: since Java doesn't allow creating a generic array with
new T[], the implementation of this operator has to create anObject[]instead. Unfortunately, aFunction<Integer[], R>passed to the method would trigger aClassCastException.This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common value typeR- the zipped result type- Parameters:
sources- anIterableof sourceMaybeSourceszipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifzipperorsourcesisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceT5- the value type of the fifth sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcesource5- a fifth sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4,source5orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceT5- the value type of the fifth sourceT6- the value type of the sixth sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcesource5- a fifth sourceMaybeSourcesource6- a sixth sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4,source5,source6orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceT5- the value type of the fifth sourceT6- the value type of the sixth sourceT7- the value type of the seventh sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcesource5- a fifth sourceMaybeSourcesource6- a sixth sourceMaybeSourcesource7- a seventh sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4,source5,source6,source7orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull @NonNull MaybeSource<? extends @NonNull T8> source8, @NonNull @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceT5- the value type of the fifth sourceT6- the value type of the sixth sourceT7- the value type of the seventh sourceT8- the value type of the eighth sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcesource5- a fifth sourceMaybeSourcesource6- a sixth sourceMaybeSourcesource7- a seventh sourceMaybeSourcesource8- an eighth sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4,source5,source6,source7,source8orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R> @NonNull Maybe<R> zip(@NonNull @NonNull MaybeSource<? extends @NonNull T1> source1, @NonNull @NonNull MaybeSource<? extends @NonNull T2> source2, @NonNull @NonNull MaybeSource<? extends @NonNull T3> source3, @NonNull @NonNull MaybeSource<? extends @NonNull T4> source4, @NonNull @NonNull MaybeSource<? extends @NonNull T5> source5, @NonNull @NonNull MaybeSource<? extends @NonNull T6> source6, @NonNull @NonNull MaybeSource<? extends @NonNull T7> source7, @NonNull @NonNull MaybeSource<? extends @NonNull T8> source8, @NonNull @NonNull MaybeSource<? extends @NonNull T9> source9, @NonNull @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> zipper)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherMaybeSources.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipdoes not operate by default on a particularScheduler.
- Type Parameters:
T1- the value type of the first sourceT2- the value type of the second sourceT3- the value type of the third sourceT4- the value type of the fourth sourceT5- the value type of the fifth sourceT6- the value type of the sixth sourceT7- the value type of the seventh sourceT8- the value type of the eighth sourceT9- the value type of the ninth sourceR- the zipped result type- Parameters:
source1- the first sourceMaybeSourcesource2- a second sourceMaybeSourcesource3- a third sourceMaybeSourcesource4- a fourth sourceMaybeSourcesource5- a fifth sourceMaybeSourcesource6- a sixth sourceMaybeSourcesource7- a seventh sourceMaybeSourcesource8- an eighth sourceMaybeSourcesource9- a ninth sourceMaybeSourcezipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsource1,source2,source3,source4,source5,source6,source7,source8,source9orzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
zipArray
@CheckReturnValue @NonNull @SchedulerSupport("none") @SafeVarargs public static <@NonNull T,@NonNull R> @NonNull Maybe<R> zipArray(@NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, @NonNull @NonNull MaybeSource<? extends @NonNull T>... sources)
Returns aMaybethat emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherMaybeSources.Note on method signature: since Java doesn't allow creating a generic array with
new T[], the implementation of this operator has to create anObject[]instead. Unfortunately, aFunction<Integer[], R>passed to the method would trigger aClassCastException.
This operator terminates eagerly if any of the source
MaybeSources signal anonErrororonComplete. This also means it is possible some sources may not get subscribed to at all.- Scheduler:
zipArraydoes not operate by default on a particularScheduler.
- Type Parameters:
T- the common element typeR- the result type- Parameters:
sources- an array of sourceMaybeSourceszipper- a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsourcesorzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
ambWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> ambWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Mirrors theMaybeSource(current or provided) that first signals an event.
- Scheduler:
ambWithdoes not operate by default on a particularScheduler.
- Parameters:
other- aMaybeSourcecompeting to react first. A subscription to this provided source will occur after subscribing to the current source.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifotherisnull- See Also:
- ReactiveX operators documentation: Amb
-
blockingGet
@CheckReturnValue @SchedulerSupport("none") @Nullable public final T blockingGet()
Waits in a blocking fashion until the currentMaybesignals a success value (which is returned),nullif completed or an exception (which is propagated).
- Scheduler:
blockingGetdoes not operate by default on a particularScheduler.- Error handling:
- If the source signals an error, the operator wraps a checked
ExceptionintoRuntimeExceptionand throws that. Otherwise,RuntimeExceptions andErrors are rethrown as they are.
- Returns:
- the success value
-
blockingGet
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingGet(@NonNull @NonNull T defaultValue)
Waits in a blocking fashion until the currentMaybesignals a success value (which is returned), defaultValue if completed or an exception (which is propagated).
- Scheduler:
blockingGetdoes not operate by default on a particularScheduler.- Error handling:
- If the source signals an error, the operator wraps a checked
ExceptionintoRuntimeExceptionand throws that. Otherwise,RuntimeExceptions andErrors are rethrown as they are.
- Parameters:
defaultValue- the default item to return if thisMaybeis empty- Returns:
- the success value
- Throws:
java.lang.NullPointerException- ifdefaultValueisnull
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe()
Subscribes to the currentMaybeand blocks the current thread until it terminates.
- Scheduler:
blockingSubscribedoes not operate by default on a particularScheduler.- Error handling:
- If the current
Maybesignals an error, theThrowableis routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, anInterruptedExceptionis routed to the same global error handler.
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess)
Subscribes to the currentMaybeand calls givenonSuccesscallback on the current thread when it completes normally.
- Scheduler:
blockingSubscribedoes not operate by default on a particularScheduler.- Error handling:
- If either the current
Maybesignals an error oronSuccessthrows, the respectiveThrowableis routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, anInterruptedExceptionis routed to the same global error handler.
- Parameters:
onSuccess- theConsumerto call if the currentMaybesucceeds- Throws:
java.lang.NullPointerException- ifonSuccessisnull- Since:
- 3.0.0
- See Also:
blockingSubscribe(Consumer, Consumer),blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentMaybeand calls the appropriate callback on the current thread when it terminates.
- Scheduler:
blockingSubscribedoes not operate by default on a particularScheduler.- Error handling:
- If either
onSuccessoronErrorthrow, theThrowableis routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, theonErrorconsumer is called with anInterruptedException.
- Parameters:
onSuccess- theConsumerto call if the currentMaybesucceedsonError- theConsumerto call if the currentMaybesignals an error- Throws:
java.lang.NullPointerException- ifonSuccessoronErrorisnull- Since:
- 3.0.0
- See Also:
blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to the currentMaybeand calls the appropriate callback on the current thread when it terminates.
- Scheduler:
blockingSubscribedoes not operate by default on a particularScheduler.- Error handling:
- If either
onSuccess,onErrororonCompletethrow, theThrowableis routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, theonErrorconsumer is called with anInterruptedException.
- Parameters:
onSuccess- theConsumerto call if the currentMaybesucceedsonError- theConsumerto call if the currentMaybesignals an erroronComplete- theActionto call if the currentMaybecompletes without a value- Throws:
java.lang.NullPointerException- ifonSuccess,onErrororonCompleteisnull- Since:
- 3.0.0
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull MaybeObserver<? super @NonNull T> observer)
Subscribes to the currentMaybeand calls the appropriateMaybeObservermethod on the current thread.
- Scheduler:
blockingSubscribedoes not operate by default on a particularScheduler.- Error handling:
- An
onErrorsignal is delivered to theMaybeObserver.onError(Throwable)method. If any of theMaybeObserver's methods throw, theRuntimeExceptionis propagated to the caller of this method. If the current thread is interrupted, anInterruptedExceptionis delivered toobserver.onError.
- Parameters:
observer- theMaybeObserverto call methods on the current thread- Throws:
java.lang.NullPointerException- ifobserverisnull- Since:
- 3.0.0
-
cache
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> cache()
Returns aMaybethat subscribes to thisMaybelazily, 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:
cachedoes not operate by default on a particularScheduler.
- Returns:
- the new
Maybeinstance - See Also:
- ReactiveX operators documentation: Replay
-
cast
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<U> cast(@NonNull @NonNull java.lang.Class<? extends @NonNull U> clazz)
Casts the success value of the currentMaybeinto the target type or signals aClassCastExceptionif not compatible.
- Scheduler:
castdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the target type- Parameters:
clazz- the type token to use for casting the success result from the currentMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifclazzisnull
-
compose
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Maybe<R> compose(@NonNull @NonNull MaybeTransformer<? super @NonNull T,? extends @NonNull R> transformer)
Transform aMaybeby applying a particularMaybeTransformerfunction to it.
This method operates on the
Maybeitself whereaslift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>)operates on theMaybe'sMaybeObservers.If the operator you are creating is designed to act on the individual item emitted by a
Maybe, uselift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>). If your operator is designed to transform the currentMaybeas a whole (for instance, by applying a particular set of existing RxJava operators to it) usecompose.- Scheduler:
composedoes not operate by default on a particularScheduler.
- Type Parameters:
R- the value type of theMaybereturned by the transformer function- Parameters:
transformer- the transformer function, notnull- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iftransformerisnull- See Also:
- RxJava wiki: Implementing Your Own Operators
-
concatMap
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Returns aMaybethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.
Note that flatMap and concatMap for
Maybeis the same operation.- Scheduler:
concatMapdoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aMaybeSource- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Completable concatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Returns aCompletablethat completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.
This operator is an alias for
flatMapCompletable(Function).- Scheduler:
concatMapCompletabledoes not operate by default on a particularScheduler.
- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aCompletable- Returns:
- the new
Completableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapSingle
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> concatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns aMaybebased on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. When thisMaybejust completes the resultingMaybecompletes as well.
This operator is an alias for
flatMapSingle(Function).- Scheduler:
concatMapSingledoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aSingle- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatWith
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Flowable<T> concatWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Returns aFlowablethat emits the items emitted from the currentMaybe, then theotherMaybeSource, one after the other, without interleaving them.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
concatWithdoes not operate by default on a particularScheduler.
- Parameters:
other- aMaybeSourceto be concatenated after the current- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- See Also:
- ReactiveX operators documentation: Concat
-
contains
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Single<java.lang.Boolean> contains(@NonNull @NonNull java.lang.Object item)
Returns aSinglethat emits aBooleanthat indicates whether the currentMaybeemitted a specified item.
- Scheduler:
containsdoes not operate by default on a particularScheduler.
- Parameters:
item- the item to search for in the emissions from the currentMaybe, notnull- Returns:
- the new
Singleinstance - Throws:
java.lang.NullPointerException- ifitemisnull- See Also:
- ReactiveX operators documentation: Contains
-
count
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Long> count()
Returns aSinglethat counts the total number of items emitted (0 or 1) by the currentMaybeand emits this count as a 64-bitLong.
- Scheduler:
countdoes not operate by default on a particularScheduler.
- Returns:
- the new
Singleinstance - See Also:
- ReactiveX operators documentation: Count
-
defaultIfEmpty
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Single<T> defaultIfEmpty(@NonNull @NonNull T defaultItem)
Returns aSinglethat emits the item emitted by the currentMaybeor a specified default item if the currentMaybeis empty.
- Scheduler:
defaultIfEmptydoes not operate by default on a particularScheduler.
- Parameters:
defaultItem- the item to emit if the currentMaybeemits no items- Returns:
- the new
Singleinstance - Throws:
java.lang.NullPointerException- ifdefaultItemisnull- See Also:
- ReactiveX operators documentation: DefaultIfEmpty
-
dematerialize
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> dematerialize(@NonNull @NonNull Function<? super @NonNull T,@NonNull Notification<@NonNull R>> selector)
Maps theNotificationsuccess value of the currentMaybeback into normalonSuccess,onErrororonCompletesignals.
The intended use of the
selectorfunction is to perform a type-safe identity mapping (see example) on a source that is already of typeNotification<T>. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.Regular
onErrororonCompletesignals from the currentMaybeare passed along to the downstream.- Scheduler:
dematerializedoes not operate by default on a particularScheduler.
Example:
Maybe.just(Notification.createOnNext(1)) .dematerialize(notification -> notification) .test() .assertResult(1);- Type Parameters:
R- the result type- Parameters:
selector- the function called with the success item and should return aNotificationinstance.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifselectorisnull- Since:
- 3.0.0
- See Also:
materialize()
-
delay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay. An error signal will not be delayed.
- Scheduler:
- This version of
delayoperates by default on thecomputationScheduler.
- Parameters:
time- the delay to shift the source byunit- theTimeUnitin whichtimeis defined- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- See Also:
- ReactiveX operators documentation: Delay,
delay(long, TimeUnit, Scheduler, boolean)
-
delay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay.
- Scheduler:
- This version of
delayoperates by default on thecomputationScheduler.
- Parameters:
time- the delay to shift the source byunit- theTimeUnitin whichtimeis defineddelayError- iftrue, both success and error signals are delayed. iffalse, only success signals are delayed.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Delay,
delay(long, TimeUnit, Scheduler, boolean)
-
delay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay. An error signal will not be delayed.
- Scheduler:
- you specify the
Schedulerwhere the non-blocking wait and emission happens
- Parameters:
time- the delay to shift the source byunit- theTimeUnitin whichtimeis definedscheduler- theSchedulerto use for delaying- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- See Also:
- ReactiveX operators documentation: Delay,
delay(long, TimeUnit, Scheduler, boolean)
-
delay
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns aMaybethat signals the events emitted by the currentMaybeshifted forward in time by a specified delay running on the specifiedScheduler.
- Scheduler:
- you specify which
Schedulerthis operator will use.
- Parameters:
time- the delay to shift the source byunit- theTimeUnitin whichtimeis definedscheduler- theSchedulerto use for delayingdelayError- iftrue, both success and error signals are delayed. iffalse, only success signals are delayed.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(UNBOUNDED_IN) public final <@NonNull U> @NonNull Maybe<T> delay(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> delayIndicator)
Delays the emission of thisMaybeuntil the givenPublishersignals an item or completes.
- Backpressure:
- The
delayIndicatoris consumed in an unbounded manner but is cancelled after the first item it produces. - Scheduler:
- This version of
delaydoes not operate by default on a particularScheduler.
- Type Parameters:
U- the subscription delay value type (ignored)- Parameters:
delayIndicator- thePublisherthat gets subscribed to when thisMaybesignals an event and that signal is emitted when thePublishersignals an item or completes- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifdelayIndicatorisnull- See Also:
- ReactiveX operators documentation: Delay
-
delaySubscription
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> delaySubscription(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator)
Returns aMaybethat delays the subscription to thisMaybeuntil the otherPublisheremits an element or completes normally.
- Backpressure:
- The
Publishersource is consumed in an unbounded fashion (without applying backpressure). - Scheduler:
- This method does not operate by default on a particular
Scheduler.
- Type Parameters:
U- the value type of the otherPublisher, irrelevant- Parameters:
subscriptionIndicator- the otherPublisherthat should trigger the subscription to thisPublisher.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifsubscriptionIndicatorisnull
-
delaySubscription
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aMaybethat delays the subscription to the currentMaybeby a given amount of time.
- Scheduler:
- This version of
delaySubscriptionoperates by default on thecomputationScheduler.
- Parameters:
time- the time to delay the subscriptionunit- the time unit ofdelay- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- See Also:
- ReactiveX operators documentation: Delay,
delaySubscription(long, TimeUnit, Scheduler)
-
delaySubscription
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Maybe<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aMaybethat delays the subscription to the currentMaybeby a given amount of time, both waiting and subscribing on a givenScheduler.
- Scheduler:
- You specify which
Schedulerthis operator will use.
- Parameters:
time- the time to delay the subscriptionunit- the time unit ofdelayscheduler- theScheduleron which the waiting and subscription will happen- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- See Also:
- ReactiveX operators documentation: Delay
-
doAfterSuccess
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doAfterSuccess(@NonNull @NonNull Consumer<? super @NonNull T> onAfterSuccess)
Calls the specifiedConsumerwith the success item after this item has been emitted to the downstream.Note that the
onAfterSuccessaction is shared between subscriptions and as such should be thread-safe.
- Scheduler:
doAfterSuccessdoes not operate by default on a particularScheduler.
History: 2.0.1 - experimental
- Parameters:
onAfterSuccess- theConsumerthat will be called after emitting an item from upstream to the downstream- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonAfterSuccessisnull- Since:
- 2.1
-
doAfterTerminate
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doAfterTerminate(@NonNull @NonNull Action onAfterTerminate)
Registers anActionto be called when thisMaybeinvokes eitheronSuccess,onCompleteoronError.
- Scheduler:
doAfterTerminatedoes not operate by default on a particularScheduler.
- Parameters:
onAfterTerminate- anActionto be invoked when the currentMaybefinishes- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonAfterTerminateisnull- See Also:
- ReactiveX operators documentation: Do
-
doFinally
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doFinally(@NonNull @NonNull Action onFinally)
Calls the specified action after thisMaybesignalsonSuccess,onErrororonCompleteor gets disposed by the downstream.
In case of a race between a terminal event and a dispose call, the provided
onFinallyaction is executed once per subscription.Note that the
onFinallyaction is shared between subscriptions and as such should be thread-safe.- Scheduler:
doFinallydoes not operate by default on a particularScheduler.
History: 2.0.1 - experimental
- Parameters:
onFinally- the action called when thisMaybeterminates or gets disposed- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonFinallyisnull- Since:
- 2.1
-
doOnDispose
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnDispose(@NonNull @NonNull Action onDispose)
Calls the sharedActionif aMaybeObserversubscribed to the currentMaybedisposes the commonDisposableit received viaonSubscribe.
- Scheduler:
doOnDisposedoes not operate by default on a particularScheduler.
- Parameters:
onDispose- the action called when the subscription is disposed- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonDisposeisnull
-
doOnComplete
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnComplete(@NonNull @NonNull Action onComplete)
Invokes anActionjust before the currentMaybecallsonComplete.
- Scheduler:
doOnCompletedoes not operate by default on a particularScheduler.
- Parameters:
onComplete- the action to invoke when the currentMaybecallsonComplete- Returns:
- the new
Maybewith the side-effecting behavior applied - Throws:
java.lang.NullPointerException- ifonCompleteisnull- See Also:
- ReactiveX operators documentation: Do
-
doOnError
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnError(@NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Calls the sharedConsumerwith the error sent viaonErrorfor eachMaybeObserverthat subscribes to the currentMaybe.
- Scheduler:
doOnErrordoes not operate by default on a particularScheduler.
- Parameters:
onError- the consumer called with the success value ofonError- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonErrorisnull
-
doOnEvent
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> doOnEvent(@NonNull @NonNull BiConsumer<? super @NonNull T,? super java.lang.Throwable> onEvent)
Calls the givenonEventcallback with the (success value,null) for anonSuccess, (null, throwable) for anonErroror (null,null) for anonCompletesignal from thisMaybebefore delivering said signal to the downstream.
The exceptions thrown from the callback will override the event so the downstream receives the error instead of the original signal.
- Scheduler:
doOnEventdoes not operate by default on a particularScheduler.
- Parameters:
onEvent- the callback to call with the success value or the exception, whichever is notnull- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonEventisnull
-
doOnLifecycle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> doOnLifecycle(@NonNull @NonNull Consumer<? super Disposable> onSubscribe, @NonNull @NonNull Action onDispose)
Calls the appropriateonXXXmethod (shared between allMaybeObservers) for the lifecycle events of the sequence (subscription, disposal).
- Scheduler:
doOnLifecycledoes not operate by default on a particularScheduler.
- Parameters:
onSubscribe- aConsumercalled with theDisposablesent viaMaybeObserver.onSubscribe(Disposable)onDispose- called when the downstream disposes theDisposableviadispose()- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonSubscribeoronDisposeisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Do
-
doOnSubscribe
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnSubscribe(@NonNull @NonNull Consumer<? super Disposable> onSubscribe)
Calls the sharedConsumerwith theDisposablesent through theonSubscribefor eachMaybeObserverthat subscribes to the currentMaybe.
- Scheduler:
doOnSubscribedoes not operate by default on a particularScheduler.
- Parameters:
onSubscribe- theConsumercalled with theDisposablesent viaonSubscribe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonSubscribeisnull
-
doOnTerminate
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnTerminate(@NonNull @NonNull Action onTerminate)
Returns aMaybeinstance that calls the given onTerminate callback just before thisMaybecompletes normally or with an exception.
This differs from
doAfterTerminatein that this happens before theonCompleteoronErrornotification.- Scheduler:
doOnTerminatedoes not operate by default on a particularScheduler.
History: 2.2.7 - experimental
- Parameters:
onTerminate- the action to invoke when the consumer callsonCompleteoronError- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonTerminateisnull- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Do,
doOnTerminate(Action)
-
doOnSuccess
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> doOnSuccess(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess)
Calls the sharedConsumerwith the success value sent viaonSuccessfor eachMaybeObserverthat subscribes to the currentMaybe.
- Scheduler:
doOnSuccessdoes not operate by default on a particularScheduler.
- Parameters:
onSuccess- theConsumercalled with the success value of the upstream- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonSuccessisnull
-
filter
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> filter(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Filters the success item of theMaybevia a predicate function and emitting it if the predicate returnstrue, completing otherwise.
- Scheduler:
filterdoes not operate by default on a particularScheduler.
- Parameters:
predicate- a function that evaluates the item emitted by the currentMaybe, returningtrueif it passes the filter- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifpredicateisnull- See Also:
- ReactiveX operators documentation: Filter
-
flatMap
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Returns aMaybethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.
- Scheduler:
flatMapdoes not operate by default on a particularScheduler.
Note that flatMap and concatMap for
Maybeis the same operation.- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aMaybeSource- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> onSuccessMapper, @NonNull @NonNull Function<? super java.lang.Throwable,? extends MaybeSource<? extends @NonNull R>> onErrorMapper, @NonNull @NonNull Supplier<? extends MaybeSource<? extends @NonNull R>> onCompleteSupplier)
Maps theonSuccess,onErrororonCompletesignals of the currentMaybeinto aMaybeSourceand emits thatMaybeSource's signals.
- Scheduler:
flatMapdoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result type- Parameters:
onSuccessMapper- a function that returns aMaybeSourceto merge for theonSuccessitem emitted by thisMaybeonErrorMapper- a function that returns aMaybeSourceto merge for anonErrornotification from thisMaybeonCompleteSupplier- a function that returns aMaybeSourceto merge for anonCompletenotification thisMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifonSuccessMapper,onErrorMapperoronCompleteSupplierisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Maybe<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Returns aMaybethat emits the results of a specified function to the pair of values emitted by the currentMaybeand a specified mappedMaybeSource.
- Scheduler:
flatMapdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of items emitted by theMaybeSourcereturned by themapperfunctionR- the type of items emitted by the resultingMaybe- Parameters:
mapper- a function that returns aMaybeSourcefor the item emitted by the currentMaybecombiner- a function that combines one item emitted by each of the source and collectionMaybeSourceand returns an item to be emitted by the resultingMaybeSource- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperorcombinerisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flattenAsFlowable
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<U> flattenAsFlowable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Maps the success value of the currentMaybeinto anIterableand emits its items as aFlowablesequence.
- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
flattenAsFlowabledoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of item emitted by the innerIterable- Parameters:
mapper- a function that returns anIterablesequence of values for when given an item emitted by the currentMaybe- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap,
flattenStreamAsFlowable(Function)
-
flattenAsObservable
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Observable<U> flattenAsObservable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Maps the success value of the currentMaybeinto anIterableand emits its items as anObservablesequence.
- Scheduler:
flattenAsObservabledoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of item emitted by the resultingIterable- Parameters:
mapper- a function that returns anIterablesequence of values for when given an item emitted by the currentMaybe- Returns:
- the new
Observableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapObservable
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Observable<R> flatMapObservable(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns anObservablethat is based on applying a specified function to the item emitted by the currentMaybe, where that function returns anObservableSource.
- Scheduler:
flatMapObservabledoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns anObservableSource- Returns:
- the new
Observableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapPublisher
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMapPublisher(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns aFlowablethat emits items based on applying a specified function to the item emitted by the currentMaybe, where that function returns aPublisher.
- Backpressure:
- The returned
Flowablehonors the downstream backpressure. - Scheduler:
flatMapPublisherdoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aFlowable- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapSingle
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> flatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns aMaybebased on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. When thisMaybejust completes the resultingMaybecompletes as well.
- Scheduler:
flatMapSingledoes not operate by default on a particularScheduler.
History: 2.0.2 - experimental
- Type Parameters:
R- the result value type- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aSingle- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Completable flatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Returns aCompletablethat completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.
- Scheduler:
flatMapCompletabledoes not operate by default on a particularScheduler.
- Parameters:
mapper- a function that, when applied to the item emitted by the currentMaybe, returns aCompletable- Returns:
- the new
Completableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: FlatMap
-
hide
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> hide()
Hides the identity of thisMaybeand itsDisposable.
Allows preventing certain identity-based optimizations (fusion).
- Scheduler:
hidedoes not operate by default on a particularScheduler.
- Returns:
- the new
Maybeinstance
-
ignoreElement
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable ignoreElement()
Returns aCompletablethat ignores the item emitted by the currentMaybeand only callsonCompleteoronError.
- Scheduler:
ignoreElementdoes not operate by default on a particularScheduler.
- Returns:
- the new
Completableinstance - See Also:
- ReactiveX operators documentation: IgnoreElements
-
isEmpty
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> isEmpty()
Returns aSinglethat emitstrueif the currentMaybeis empty, otherwisefalse.
- Scheduler:
isEmptydoes not operate by default on a particularScheduler.
- Returns:
- the new
Singleinstance - See Also:
- ReactiveX operators documentation: Contains
-
lift
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> lift(@NonNull @NonNull MaybeOperator<? extends @NonNull R,? super @NonNull T> lift)
This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aMaybewhich, when subscribed to, invokes theapply(MaybeObserver)method of the providedMaybeOperatorfor each individual downstreamMaybeand allows the insertion of a custom operator by accessing the downstream'sMaybeObserverduring this subscription phase and providing a newMaybeObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.
Generally, such a new
MaybeObserverwill wrap the downstream'sMaybeObserverand forwards theonSuccess,onErrorandonCompleteevents from the upstream directly or according to the emission pattern the custom operator's business logic requires. In addition, such operator can intercept the flow control calls ofdisposeandisDisposedthat would have traveled upstream and perform additional actions depending on the same business logic requirements.Example:
// Step 1: Create the consumer type that will be returned by the MaybeOperator.apply(): public final class CustomMaybeObserver<T> implements MaybeObserver<T>, Disposable { // The downstream's MaybeObserver that will receive the onXXX events final MaybeObserver<? super String> downstream; // The connection to the upstream source that will call this class' onXXX methods Disposable upstream; // The constructor takes the downstream subscriber and usually any other parameters public CustomMaybeObserver(MaybeObserver<? super String> downstream) { this.downstream = downstream; } // In the subscription phase, the upstream sends a Disposable to this class // and subsequently this class has to send a Disposable to the downstream. // Note that relaying the upstream's Disposable directly is not allowed in RxJava @Override public void onSubscribe(Disposable d) { if (upstream != null) { d.dispose(); } else { upstream = d; downstream.onSubscribe(this); } } // The upstream calls this with the next item and the implementation's // responsibility is to emit an item to the downstream based on the intended // business logic, or if it can't do so for the particular item, // request more from the upstream @Override public void onSuccess(T item) { String str = item.toString(); if (str.length() < 2) { downstream.onSuccess(str); } else { // Maybe is expected to produce one of the onXXX events only downstream.onComplete(); } } // Some operators may handle the upstream's error while others // could just forward it to the downstream. @Override public void onError(Throwable throwable) { downstream.onError(throwable); } // When the upstream completes, usually the downstream should complete as well. @Override public void onComplete() { downstream.onComplete(); } // Some operators may use their own resources which should be cleaned up if // the downstream disposes the flow before it completed. Operators without // resources can simply forward the dispose to the upstream. // In some cases, a disposed flag may be set by this method so that other parts // of this class may detect the dispose and stop sending events // to the downstream. @Override public void dispose() { upstream.dispose(); } // Some operators may simply forward the call to the upstream while others // can return the disposed flag set in dispose(). @Override public boolean isDisposed() { return upstream.isDisposed(); } } // Step 2: Create a class that implements the MaybeOperator interface and // returns the custom consumer type from above in its apply() method. // Such class may define additional parameters to be submitted to // the custom consumer type. final class CustomMaybeOperator<T> implements MaybeOperator<String> { @Override public MaybeObserver<? super String> apply(MaybeObserver<? super T> upstream) { return new CustomMaybeObserver<T>(upstream); } } // Step 3: Apply the custom operator via lift() in a flow by creating an instance of it // or reusing an existing one. Maybe.just(5) .lift(new CustomMaybeOperator<Integer>()) .test() .assertResult("5"); Maybe.just(15) .lift(new CustomMaybeOperator<Integer>()) .test() .assertResult();Creating custom operators can be complicated and it is recommended one consults the RxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via this
lift()method adds slightly more overhead by requiring an additional allocation and indirection per assembled flows. Instead, extending the abstractMaybeclass and creating aMaybeTransformerwith it is recommended.Note also that it is not possible to stop the subscription phase in
lift()as theapply()method requires a non-nullMaybeObserverinstance to be returned, which is then unconditionally subscribed to the currentMaybe. For example, if the operator decided there is no reason to subscribe to the upstream source because of some optimization possibility or a failure to prepare the operator, it still has to return aMaybeObserverthat should immediately dispose the upstream'sDisposablein itsonSubscribemethod. Again, using aMaybeTransformerand extending theMaybeis a better option assubscribeActual(io.reactivex.rxjava3.core.MaybeObserver<? super T>)can decide to not subscribe to its upstream after all.- Scheduler:
liftdoes not operate by default on a particularScheduler, however, theMaybeOperatormay use aSchedulerto support its own asynchronous behavior.
- Type Parameters:
R- the output value type- Parameters:
lift- theMaybeOperatorthat receives the downstream'sMaybeObserverand should return aMaybeObserverwith custom behavior to be used as the consumer for the currentMaybe.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifliftisnull- See Also:
- RxJava wiki: Writing operators,
compose(MaybeTransformer)
-
map
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull R> @NonNull Maybe<R> map(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)
Returns aMaybethat applies a specified function to the item emitted by the currentMaybeand emits the result of this function application.
- Scheduler:
mapdoes not operate by default on a particularScheduler.
- Type Parameters:
R- the result value type- Parameters:
mapper- a function to apply to the item emitted by theMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- See Also:
- ReactiveX operators documentation: Map
-
materialize
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<Notification<T>> materialize()
Maps the signal types of thisMaybeinto aNotificationof the same kind and emits it as aSingle'sonSuccessvalue to downstream.
- Scheduler:
materializedoes not operate by default on a particularScheduler.
History: 2.2.4 - experimental
- Returns:
- the new
Singleinstance - Since:
- 3.0.0
- See Also:
Single.dematerialize(Function)
-
mergeWith
@BackpressureSupport(FULL) @CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Flowable<T> mergeWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Flattens thisMaybeand anotherMaybeSourceinto a singleFlowable, without any transformation.
You can combine items emitted by multiple
Maybes so that they appear as a singleFlowable, by using themergeWithmethod.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
mergeWithdoes not operate by default on a particularScheduler.
- Parameters:
other- aMaybeSourceto be merged- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- See Also:
- ReactiveX operators documentation: Merge
-
observeOn
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<T> observeOn(@NonNull @NonNull Scheduler scheduler)
Wraps aMaybeto emit its item (or notify of its error) on a specifiedScheduler, asynchronously.
- Scheduler:
- you specify which
Schedulerthis operator will use.
- Parameters:
scheduler- theSchedulerto notify subscribers on- Returns:
- the new
Maybeinstance that its subscribers are notified on the specifiedScheduler - Throws:
java.lang.NullPointerException- ifschedulerisnull- See Also:
- ReactiveX operators documentation: ObserveOn,
RxJava Threading Examples,
subscribeOn(io.reactivex.rxjava3.core.Scheduler)
-
ofType
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<U> ofType(@NonNull @NonNull java.lang.Class<@NonNull U> clazz)
Filters the items emitted by the currentMaybe, only emitting its success value if that is an instance of the suppliedClass.
- Scheduler:
ofTypedoes not operate by default on a particularScheduler.
- Type Parameters:
U- the output type- Parameters:
clazz- the class type to filter the items emitted by the currentMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifclazzisnull- See Also:
- ReactiveX operators documentation: Filter
-
to
@CheckReturnValue @SchedulerSupport("none") public final <R> R to(@NonNull @NonNull MaybeConverter<@NonNull T,? extends R> converter)
Calls the specified converter function during assembly time and returns its resulting value.
This allows fluent conversion to any other type.
- Scheduler:
todoes not operate by default on a particularScheduler.
History: 2.1.7 - experimental
- Type Parameters:
R- the resulting object type- Parameters:
converter- the function that receives the currentMaybeinstance and returns a value- Returns:
- the converted value
- Throws:
java.lang.NullPointerException- ifconverterisnull- Since:
- 2.2
-
toFlowable
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> toFlowable()
Converts thisMaybeinto a backpressure-awareFlowableinstance composing cancellation through.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream. - Scheduler:
toFlowabledoes not operate by default on a particularScheduler.
- Returns:
- the new
Flowableinstance
-
toFuture
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.Future<T> toFuture()
Returns aFuturerepresenting the single value emitted by the currentMaybeornullif the currentMaybeis empty.
Cancelling the
Futurewill cancel the subscription to the currentMaybe.- Scheduler:
toFuturedoes not operate by default on a particularScheduler.
- Returns:
- the new
Futureinstance - Since:
- 3.0.0
- See Also:
- ReactiveX documentation: To
-
toObservable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> toObservable()
Converts thisMaybeinto anObservableinstance composing disposal through.
- Scheduler:
toObservabledoes not operate by default on a particularScheduler.
- Returns:
- the new
Observableinstance
-
toSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> toSingle()
Converts thisMaybeinto aSingleinstance composing disposal through and turning an emptyMaybeinto a signal ofNoSuchElementException.
- Scheduler:
toSingledoes not operate by default on a particularScheduler.
- Returns:
- the new
Singleinstance - See Also:
defaultIfEmpty(Object)
-
onErrorComplete
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> onErrorComplete()
Returns aMaybeinstance that if thisMaybeemits an error, it will emit anonCompleteand swallow the throwable.
- Scheduler:
onErrorCompletedoes not operate by default on a particularScheduler.
- Returns:
- the new
Maybeinstance
-
onErrorComplete
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> onErrorComplete(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Returns aMaybeinstance that if thisMaybeemits an error and the predicate returnstrue, it will emit anonCompleteand swallow the throwable.
- Scheduler:
onErrorCompletedoes not operate by default on a particularScheduler.
- Parameters:
predicate- the predicate to call when anThrowableis emitted which should returntrueif theThrowableshould be swallowed and replaced with anonComplete.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifpredicateisnull
-
onErrorResumeWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> onErrorResumeWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> fallback)
Resumes the flow with the givenMaybeSourcewhen the currentMaybefails instead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorResumeWithdoes not operate by default on a particularScheduler.
- Parameters:
fallback- the nextMaybeSourcethat will take over if the currentMaybeencounters an error- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iffallbackisnull- See Also:
- ReactiveX operators documentation: Catch
-
onErrorResumeNext
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> onErrorResumeNext(@NonNull @NonNull Function<? super java.lang.Throwable,? extends MaybeSource<? extends @NonNull T>> fallbackSupplier)
Resumes the flow with aMaybeSourcereturned for the failureThrowableof the currentMaybeby a function instead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorResumeNextdoes not operate by default on a particularScheduler.
- Parameters:
fallbackSupplier- a function that returns aMaybeSourcethat will take over if the currentMaybeencounters an error- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iffallbackSupplierisnull- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturn
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> onErrorReturn(@NonNull @NonNull Function<? super java.lang.Throwable,? extends @NonNull T> itemSupplier)
Ends the flow with a success item returned by a function for theThrowableerror signaled by the currentMaybeinstead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorReturndoes not operate by default on a particularScheduler.
- Parameters:
itemSupplier- a function that returns a single value that will be emitted as success value the currentMaybesignals anonErrorevent- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifitemSupplierisnull- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturnItem
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> onErrorReturnItem(@NonNull @NonNull T item)
Ends the flow with the given success item when the currentMaybefails instead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorReturnItemdoes not operate by default on a particularScheduler.
- Parameters:
item- the value that is emitted asonSuccessin case the currentMaybesignals anonError- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifitemisnull- See Also:
- ReactiveX operators documentation: Catch
-
onTerminateDetach
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> onTerminateDetach()
Nulls out references to the upstream producer and downstreamMaybeObserverif the sequence is terminated or downstream callsdispose().
- Scheduler:
onTerminateDetachdoes not operate by default on a particularScheduler.
- Returns:
- the new
Maybeinstance the sequence is terminated or downstream callsdispose()
-
repeat
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeat()
Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeindefinitely.
- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
repeatdoes not operate by default on a particularScheduler.
- Returns:
- the new
Flowableinstance - See Also:
- ReactiveX operators documentation: Repeat
-
repeat
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeat(long times)
Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeat mostcounttimes.
- Backpressure:
- This operator honors downstream backpressure.
- Scheduler:
repeatdoes not operate by default on a particularScheduler.
- Parameters:
times- the number of times the currentMaybeitems are repeated, a count of 0 will yield an empty sequence- Returns:
- the new
Flowableinstance - Throws:
java.lang.IllegalArgumentException- iftimesis negative- See Also:
- ReactiveX operators documentation: Repeat
-
repeatUntil
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeatUntil(@NonNull @NonNull BooleanSupplier stop)
Returns aFlowablethat repeats the sequence of items emitted by the currentMaybeuntil the provided stop function returnstrue.
- Backpressure:
- This operator honors downstream backpressure.
- Scheduler:
repeatUntildoes not operate by default on a particularScheduler.
- Parameters:
stop- a boolean supplier that is called when the currentFlowablecompletes and unless it returnsfalse, the currentFlowableis resubscribed- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifstopisnull- See Also:
- ReactiveX operators documentation: Repeat
-
repeatWhen
@BackpressureSupport(FULL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeatWhen(@NonNull @NonNull Function<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aFlowablethat emits the same values as the currentMaybewith the exception of anonComplete. AnonCompletenotification from the source will result in the emission of avoiditem to theFlowableprovided as an argument to thenotificationHandlerfunction. If thatPublishercallsonCompleteoronErrorthenrepeatWhenwill callonCompleteoronErroron the child observer. Otherwise, this operator will resubscribe to the currentMaybe.
- Backpressure:
- The operator honors downstream backpressure and expects the source
Publisherto honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException. - Scheduler:
repeatWhendoes not operate by default on a particularScheduler.
- Parameters:
handler- receives aPublisherof notifications with which a user can complete or error, aborting the repeat.- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifhandlerisnull- See Also:
- ReactiveX operators documentation: Repeat
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retry()
Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonError(infinite retry count).
If the current
MaybecallsMaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the currentMayberather than propagating theonErrorcall.- Scheduler:
retrydoes not operate by default on a particularScheduler.
- Returns:
- the new
Maybeinstance - See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retry(@NonNull @NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonErrorand the predicate returnstruefor that specific exception and retry count.
- Scheduler:
retrydoes not operate by default on a particularScheduler.
- Parameters:
predicate- the predicate that determines if a resubscription may happen in case of a specific exception and retry count- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifpredicateisnull- See Also:
retry(), ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retry(long times)
Returns aMaybethat mirrors the currentMaybe, resubscribing to it if it callsonErrorup to a specified number of retries.
If the current
MaybecallsMaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the currentMaybefor a maximum ofcountresubscriptions rather than propagating theonErrorcall.- Scheduler:
retrydoes not operate by default on a particularScheduler.
- Parameters:
times- the number of times to resubscribe if the currentMaybefails- Returns:
- the new
Maybeinstance - Throws:
java.lang.IllegalArgumentException- iftimesis negative- See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retry(long times, @NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries at mosttimesor until the predicate returnsfalse, whichever happens first.
- Scheduler:
retrydoes not operate by default on a particularScheduler.
- Parameters:
times- the number of times to resubscribe if the currentMaybefailspredicate- the predicate called with the failureThrowableand should returntrueto trigger a retry.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifpredicateisnulljava.lang.IllegalArgumentException- iftimesis negative
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retry(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries the currentMaybeif it fails and the predicate returnstrue.
- Scheduler:
retrydoes not operate by default on a particularScheduler.
- Parameters:
predicate- the predicate that receives the failureThrowableand should returntrueto trigger a retry.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifpredicateisnull
-
retryUntil
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> retryUntil(@NonNull @NonNull BooleanSupplier stop)
Retries until the given stop function returnstrue.
- Scheduler:
retryUntildoes not operate by default on a particularScheduler.
- Parameters:
stop- the function that should returntrueto stop retrying- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifstopisnull
-
retryWhen
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> retryWhen(@NonNull @NonNull Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aMaybethat emits the same values as the currentMaybewith the exception of anonError. AnonErrornotification from the source will result in the emission of aThrowableitem to theFlowableprovided as an argument to thenotificationHandlerfunction. If the returnedPublishercallsonCompleteoronErrorthenretrywill callonCompleteoronErroron the child subscription. Otherwise, this operator will resubscribe to the currentMaybe.
Example: This retries 3 times, each time incrementing the number of seconds it waits.
Output is:Maybe.create((MaybeEmitter<? 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 Flowable.timer(i, TimeUnit.SECONDS); }); }).blockingForEach(System.out::println);subscribing delay retry by 1 second(s) subscribing delay retry by 2 second(s) subscribing delay retry by 3 second(s) subscribingNote that the inner
Publisherreturned by the handler function should signal eitheronNext,onErrororonCompletein response to the receivedThrowableto indicate the operator should retry or terminate. If the upstream to the operator is asynchronous, signallingonNextfollowed byonCompleteimmediately may result in the sequence to be completed immediately. Similarly, if this innerPublishersignalsonErrororonCompletewhile the upstream is active, the sequence is terminated with the same signal immediately.The following example demonstrates how to retry an asynchronous source with a delay:
Maybe.timer(1, TimeUnit.SECONDS) .doOnSubscribe(s -> System.out.println("subscribing")) .map(v -> { throw new RuntimeException(); }) .retryWhen(errors -> { AtomicInteger counter = new AtomicInteger(); return errors .takeWhile(e -> counter.getAndIncrement() != 3) .flatMap(e -> { System.out.println("delay retry by " + counter.get() + " second(s)"); return Flowable.timer(counter.get(), TimeUnit.SECONDS); }); }) .blockingGet();- Scheduler:
retryWhendoes not operate by default on a particularScheduler.
- Parameters:
handler- receives aPublisherof notifications with which a user can complete or error, aborting the retry- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifhandlerisnull- See Also:
- ReactiveX operators documentation: Retry
-
safeSubscribe
@SchedulerSupport("none") public final void safeSubscribe(@NonNull @NonNull MaybeObserver<? super @NonNull T> observer)
Wraps the givenMaybeObserver, catches anyRuntimeExceptions thrown by itsMaybeObserver.onSubscribe(Disposable),MaybeObserver.onSuccess(Object),MaybeObserver.onError(Throwable)orMaybeObserver.onComplete()methods and routes those to the global error handler viaRxJavaPlugins.onError(Throwable).By default, the
Maybeprotocol forbids theonXXXmethods to throw, but someMaybeObserverimplementation may do it anyway, causing undefined behavior in the upstream. This method and the underlying safe wrapper ensures such misbehaving consumers don't disrupt the protocol.- Scheduler:
safeSubscribedoes not operate by default on a particularScheduler.
- Parameters:
observer- the potentially misbehavingMaybeObserver- Throws:
java.lang.NullPointerException- ifobserverisnull- Since:
- 3.0.0
- See Also:
subscribe(Consumer,Consumer, Action)
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull CompletableSource other)
Returns aFlowablewhich first runs the otherCompletableSourcethen the currentMaybeif the other completed normally.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
startWithdoes not operate by default on a particularScheduler.
- Parameters:
other- the otherCompletableSourceto run first- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull SingleSource<@NonNull T> other)
Returns aFlowablewhich first runs the otherSingleSourcethen the currentMaybeif the other succeeded normally.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
startWithdoes not operate by default on a particularScheduler.
- Parameters:
other- the otherSingleSourceto run first- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull MaybeSource<@NonNull T> other)
Returns aFlowablewhich first runs the otherMaybeSourcethen the currentMaybeif the other succeeded or completed normally.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer. - Scheduler:
startWithdoes not operate by default on a particularScheduler.
- Parameters:
other- the otherMaybeSourceto run first- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Observable<T> startWith(@NonNull @NonNull ObservableSource<@NonNull T> other)
Returns anObservablewhich first delivers the events of the otherObservableSourcethen runs the currentMaybe.
- Scheduler:
startWithdoes not operate by default on a particularScheduler.
- Parameters:
other- the otherObservableSourceto run first- Returns:
- the new
Observableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> startWith(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T> other)
Returns aFlowablewhich first delivers the events of the otherPublisherthen runs the currentMaybe.
- Backpressure:
- The returned
Flowablehonors the backpressure of the downstream consumer and expects the otherPublisherto honor it as well. - Scheduler:
startWithdoes not operate by default on a particularScheduler.
- Parameters:
other- the otherPublisherto run first- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 3.0.0
-
subscribe
@SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe()
Subscribes to aMaybeand ignoresonSuccessandonCompleteemissions.If the
Maybeemits an error, it is wrapped into anOnErrorNotImplementedExceptionand routed to theRxJavaPlugins.onError(Throwable)handler.- Scheduler:
subscribedoes not operate by default on a particularScheduler.
- Returns:
- the new
Disposableinstance that can be used for disposing the subscription at any time - See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess)
Subscribes to aMaybeand provides a callback to handle the items it emits.If the
Maybeemits an error, it is wrapped into anOnErrorNotImplementedExceptionand routed to theRxJavaPlugins.onError(Throwable)handler.- Scheduler:
subscribedoes not operate by default on a particularScheduler.
- Parameters:
onSuccess- theConsumer<T>you have designed to accept a success value from theMaybe- Returns:
- the new
Disposableinstance that can be used for disposing the subscription at any time - Throws:
java.lang.NullPointerException- ifonSuccessisnull- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to aMaybeand provides callbacks to handle the items it emits and any error notification it issues.- Scheduler:
subscribedoes not operate by default on a particularScheduler.
- Parameters:
onSuccess- theConsumer<T>you have designed to accept a success value from theMaybeonError- theConsumer<Throwable>you have designed to accept any error notification from theMaybe- Returns:
- the new
Disposableinstance that can be used for disposing the subscription at any time - Throws:
java.lang.NullPointerException- ifonSuccessisnull, or ifonErrorisnull- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to aMaybeand provides callbacks to handle the items it emits and any error or completion notification it issues.- Scheduler:
subscribedoes not operate by default on a particularScheduler.
- Parameters:
onSuccess- theConsumer<T>you have designed to accept a success value from theMaybeonError- theConsumer<Throwable>you have designed to accept any error notification from theMaybeonComplete- theActionyou have designed to accept a completion notification from theMaybe- Returns:
- the new
Disposableinstance that can be used for disposing the subscription at any time - Throws:
java.lang.NullPointerException- ifonSuccess,onErrororonCompleteisnull- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onSuccess, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete, @NonNull @NonNull DisposableContainer container)
Wraps the given onXXX callbacks into aDisposableMaybeObserver, adds it to the givenDisposableContainerand ensures, that if the upstream terminates or this particularDisposableis disposed, theMaybeObserveris removed from the given composite.The
MaybeObserverwill be removed after the callback for the terminal event has been invoked.- Scheduler:
subscribedoes not operate by default on a particularScheduler.
- Parameters:
onSuccess- the callback for upstream itemsonError- the callback for an upstream erroronComplete- the callback for an upstream completion without any value or errorcontainer- theDisposableContainer(such asCompositeDisposable) to add and remove the createdDisposableMaybeObserver- Returns:
- the
Disposablethat allows disposing the particular subscription. - Throws:
java.lang.NullPointerException- ifonSuccess,onError,onCompleteorcontainerisnull- Since:
- 3.1.0
-
subscribe
@SchedulerSupport("none") public final void subscribe(@NonNull @NonNull MaybeObserver<? super @NonNull T> observer)
Description copied from interface:MaybeSourceSubscribes the givenMaybeObserverto thisMaybeSourceinstance.- Specified by:
subscribein interfaceMaybeSource<T>- Parameters:
observer- theMaybeObserver, notnull
-
subscribeActual
protected abstract void subscribeActual(@NonNull @NonNull MaybeObserver<? super @NonNull T> observer)
Implement this method in subclasses to handle the incomingMaybeObservers.There is no need to call any of the plugin hooks on the current
Maybeinstance or theMaybeObserver; all hooks and basic safeguards have been applied bysubscribe(MaybeObserver)before this method gets called.- Parameters:
observer- theMaybeObserverto handle, notnull
-
subscribeOn
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<T> subscribeOn(@NonNull @NonNull Scheduler scheduler)
Asynchronously subscribes subscribers to thisMaybeon the specifiedScheduler.
- Scheduler:
- you specify which
Schedulerthis operator will use.
- Parameters:
scheduler- theSchedulerto perform subscription actions on- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifschedulerisnull- See Also:
- ReactiveX operators documentation: SubscribeOn,
RxJava Threading Examples,
observeOn(io.reactivex.rxjava3.core.Scheduler)
-
subscribeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull E extends MaybeObserver<? super @NonNull T>> E subscribeWith(@NonNull E observer)
Subscribes a givenMaybeObserver(subclass) to thisMaybeand returns the givenMaybeObserveras is.Usage example:
Maybe<Integer> source = Maybe.just(1); CompositeDisposable composite = new CompositeDisposable(); DisposableMaybeObserver<Integer> ds = new DisposableMaybeObserver<>() { // ... }; composite.add(source.subscribeWith(ds));- Scheduler:
subscribeWithdoes not operate by default on a particularScheduler.
- Type Parameters:
E- the type of theMaybeObserverto use and return- Parameters:
observer- theMaybeObserver(subclass) to use and return, notnull- Returns:
- the input
observer - Throws:
java.lang.NullPointerException- ifobserverisnull
-
switchIfEmpty
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Maybe<T> switchIfEmpty(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Returns aMaybethat emits the items emitted by the currentMaybeor the items of an alternateMaybeSourceif the currentMaybeis empty.
- Scheduler:
switchIfEmptydoes not operate by default on a particularScheduler.
- Parameters:
other- the alternateMaybeSourceto subscribe to if the main does not emit any items- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifotherisnull
-
switchIfEmpty
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Single<T> switchIfEmpty(@NonNull @NonNull SingleSource<? extends @NonNull T> other)
Returns aSinglethat emits the items emitted by the currentMaybeor the item of an alternateSingleSourceif the currentMaybeis empty.
- Scheduler:
switchIfEmptydoes not operate by default on a particularScheduler.
History: 2.1.4 - experimental
- Parameters:
other- the alternateSingleSourceto subscribe to if the main does not emit any items- Returns:
- the new
Singleinstance - Throws:
java.lang.NullPointerException- ifotherisnull- Since:
- 2.2
-
takeUntil
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> takeUntil(@NonNull @NonNull MaybeSource<@NonNull U> other)
Returns aMaybethat emits the items emitted by the currentMaybeuntil a secondMaybeSourceemits an item.
- Scheduler:
takeUntildoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of items emitted byother- Parameters:
other- theMaybeSourcewhose first emitted item will causetakeUntilto stop emitting items from the currentMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifotherisnull- See Also:
- ReactiveX operators documentation: TakeUntil
-
takeUntil
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> takeUntil(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> other)
Returns aMaybethat emits the item emitted by the currentMaybeuntil a secondPublisheremits an item.
- Backpressure:
- The
Publisheris consumed in an unbounded fashion and is cancelled after the first item emitted. - Scheduler:
takeUntildoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of items emitted byother- Parameters:
other- thePublisherwhose first emitted item will causetakeUntilto stop emitting items from the sourcePublisher- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifotherisnull- See Also:
- ReactiveX operators documentation: TakeUntil
-
timeInterval
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timeInterval()
Measures the time (in milliseconds) between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timeInterval().- Scheduler:
timeIntervaluses thecomputationSchedulerfor determining the current time upon subscription and upon receiving the success item from the currentMaybe.
- Returns:
- the new
Maybeinstance - Since:
- 3.0.0
-
timeInterval
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull @NonNull Scheduler scheduler)
Measures the time (in milliseconds) between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timeInterval(Scheduler).- Scheduler:
timeIntervaluses the providedSchedulerfor determining the current time upon subscription and upon receiving the success item from the currentMaybe.
- Parameters:
scheduler- theSchedulerused for providing the current time- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifschedulerisnull- Since:
- 3.0.0
-
timeInterval
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Measures the time between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timeInterval(TimeUnit).- Scheduler:
timeIntervaluses thecomputationSchedulerfor determining the current time upon subscription and upon receiving the success item from the currentMaybe.
- Parameters:
unit- the time unit for measurement- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- Since:
- 3.0.0
-
timeInterval
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Measures the time between the subscription and success item emission of the currentMaybeand signals it as a tuple (Timed) success value.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timeInterval(TimeUnit, Scheduler).- Scheduler:
timeIntervaluses the providedSchedulerfor determining the current time upon subscription and upon receiving the success item from the currentMaybe.
- Parameters:
unit- the time unit for measurementscheduler- theSchedulerused for providing the current time- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- Since:
- 3.0.0
-
timestamp
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timestamp()
Combines the success value from the currentMaybewith the current time (in milliseconds) of its reception, using thecomputationScheduleras time source, then signals them as aTimedinstance.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timestamp().- Scheduler:
timestampuses thecomputationSchedulerfor determining the current time upon receiving the success item from the currentMaybe.
- Returns:
- the new
Maybeinstance - Since:
- 3.0.0
-
timestamp
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull @NonNull Scheduler scheduler)
Combines the success value from the currentMaybewith the current time (in milliseconds) of its reception, using the givenScheduleras time source, then signals them as aTimedinstance.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timestamp(Scheduler).- Scheduler:
timestampuses the providedSchedulerfor determining the current time upon receiving the success item from the currentMaybe.
- Parameters:
scheduler- theSchedulerused for providing the current time- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifschedulerisnull- Since:
- 3.0.0
-
timestamp
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Combines the success value from the currentMaybewith the current time of its reception, using thecomputationScheduleras time source, then signals it as aTimedinstance.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timestamp(TimeUnit).- Scheduler:
timestampuses thecomputationScheduler, for determining the current time upon receiving the success item from the currentMaybe.
- Parameters:
unit- the time unit for measurement- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- Since:
- 3.0.0
-
timestamp
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Combines the success value from the currentMaybewith the current time of its reception, using the givenScheduleras time source, then signals it as aTimedinstance.
If the current
Maybeis empty or fails, the resultingMaybewill pass along the signals to the downstream. To measure the time to termination, usematerialize()and applySingle.timestamp(TimeUnit, Scheduler).- Scheduler:
timestampuses the providedScheduler, which is used for determining the current time upon receiving the success item from the currentMaybe.
- Parameters:
unit- the time unit for measurementscheduler- theSchedulerused for providing the current time- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- Since:
- 3.0.0
-
timeout
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Maybe<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aMaybethat mirrors the currentMaybebut 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 resultingMaybeterminates and notifiesMaybeObservers of aTimeoutException.
- Scheduler:
- This version of
timeoutoperates by default on thecomputationScheduler.
- Parameters:
timeout- maximum duration between emitted items before a timeout occursunit- the unit of time that applies to thetimeoutargument.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitisnull- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public final @NonNull Maybe<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull MaybeSource<? extends @NonNull T> fallback)
Returns aMaybethat mirrors the currentMaybebut 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 currentMaybeis disposed and resultingMaybebegins instead to mirror a fallbackMaybeSource.
- Scheduler:
- This version of
timeoutoperates by default on thecomputationScheduler.
- Parameters:
timeout- maximum duration between items before a timeout occursunit- the unit of time that applies to thetimeoutargumentfallback- the fallbackMaybeSourceto use in case of a timeout- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorfallbackisnull- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull MaybeSource<? extends @NonNull T> fallback)
Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item using a specifiedScheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the currentMaybeis disposed and resultingMaybebegins instead to mirror a fallbackMaybeSource.
- Scheduler:
- You specify which
Schedulerthis operator will use.
- Parameters:
timeout- maximum duration between items before a timeout occursunit- the unit of time that applies to thetimeoutargumentfallback- theMaybeSourceto use as the fallback in case of a timeoutscheduler- theSchedulerto run the timeout timers on- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iffallback,unitorschedulerisnull- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Maybe<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aMaybethat mirrors the currentMaybebut applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resultingMaybeterminates and notifiesMaybeObservers of aTimeoutException.
- Scheduler:
- You specify which
Schedulerthis operator will use.
- Parameters:
timeout- maximum duration between items before a timeout occursunit- the unit of time that applies to thetimeoutargumentscheduler- theSchedulerto run the timeout timers on- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifunitorschedulerisnull- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> timeout(@NonNull @NonNull MaybeSource<@NonNull U> timeoutIndicator)
If the currentMaybedidn't signal an event before thetimeoutIndicatorMaybeSourcesignals, aTimeoutExceptionis signaled instead.
- Scheduler:
timeoutdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the value type of the- Parameters:
timeoutIndicator- theMaybeSourcethat indicates the timeout by signalingonSuccessoronComplete.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iftimeoutIndicatorisnull
-
timeout
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> timeout(@NonNull @NonNull MaybeSource<@NonNull U> timeoutIndicator, @NonNull @NonNull MaybeSource<? extends @NonNull T> fallback)
If the currentMaybedidn't signal an event before thetimeoutIndicatorMaybeSourcesignals, the currentMaybeis disposed and thefallbackMaybeSourcesubscribed to as a continuation.
- Scheduler:
timeoutdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the value type of the- Parameters:
timeoutIndicator- theMaybeSourcethat indicates the timeout by signalingonSuccessoronComplete.fallback- theMaybeSourcethat is subscribed to if the currentMaybetimes out- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iftimeoutIndicatororfallbackisnull
-
timeout
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> timeout(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> timeoutIndicator)
If the currentMaybesource didn't signal an event before thetimeoutIndicatorPublishersignals, aTimeoutExceptionis signaled instead.
- Backpressure:
- The
timeoutIndicatorPublisheris consumed in an unbounded manner and is cancelled after its first item. - Scheduler:
timeoutdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the value type of the- Parameters:
timeoutIndicator- thePublisherthat indicates the timeout by signalingonSuccessoronComplete.- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iftimeoutIndicatorisnull
-
timeout
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U> @NonNull Maybe<T> timeout(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> timeoutIndicator, @NonNull @NonNull MaybeSource<? extends @NonNull T> fallback)
If the currentMaybedidn't signal an event before thetimeoutIndicatorPublishersignals, the currentMaybeis disposed and thefallbackMaybeSourcesubscribed to as a continuation.
- Backpressure:
- The
timeoutIndicatorPublisheris consumed in an unbounded manner and is cancelled after its first item. - Scheduler:
timeoutdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the value type of the- Parameters:
timeoutIndicator- theMaybeSourcethat indicates the timeout by signalingonSuccessoronCompletefallback- theMaybeSourcethat is subscribed to if the currentMaybetimes out- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- iftimeoutIndicatororfallbackisnull
-
unsubscribeOn
@CheckReturnValue @NonNull @SchedulerSupport("custom") public final @NonNull Maybe<T> unsubscribeOn(@NonNull @NonNull Scheduler scheduler)
Returns aMaybewhich makes sure when aMaybeObserverdisposes theDisposable, that call is propagated up on the specifiedScheduler.
- Scheduler:
unsubscribeOncallsdispose()of the upstream on theScheduleryou specify.
- Parameters:
scheduler- the target scheduler where to execute the disposal- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifschedulerisnull
-
zipWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Maybe<R> zipWith(@NonNull @NonNull MaybeSource<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Waits until this and the otherMaybeSourcesignal a success value then applies the givenBiFunctionto those values and emits theBiFunction's resulting value to downstream.
If either this or the other
MaybeSourceis empty or signals an error, the resultingMaybewill terminate immediately and dispose the other source.- Scheduler:
zipWithdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the type of items emitted by theotherMaybeSourceR- the type of items emitted by the resultingMaybe- Parameters:
other- the otherMaybeSourcezipper- a function that combines the pairs of items from the twoMaybeSources to generate the items to be emitted by the resultingMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifotherorzipperisnull- See Also:
- ReactiveX operators documentation: Zip
-
test
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull TestObserver<T> test()
Creates aTestObserverand subscribes it to thisMaybe.- Scheduler:
testdoes not operate by default on a particularScheduler.
- Returns:
- the new
TestObserverinstance
-
test
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull TestObserver<T> test(boolean dispose)
Creates aTestObserveroptionally in cancelled state, then subscribes it to thisMaybe.- Scheduler:
testdoes not operate by default on a particularScheduler.
- Parameters:
dispose- iftrue, theTestObserverwill be disposed before subscribing to thisMaybe.- Returns:
- the new
TestObserverinstance
-
fromOptional
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Maybe<@NonNull T> fromOptional(@NonNull @NonNull java.util.Optional<@NonNull T> optional)
Converts the existing value of the provided optional into ajust(Object)or an empty optional into anempty()Maybeinstance.
Note that the operator takes an already instantiated optional reference and does not by any means create this original optional. If the optional is to be created per consumer upon subscription, use
defer(Supplier)aroundfromOptional:Maybe.defer(() -> Maybe.fromOptional(createOptional()));- Scheduler:
fromOptionaldoes not operate by default on a particularScheduler.
- Type Parameters:
T- the element type of the optional value- Parameters:
optional- the optional value to convert into aMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifoptionalisnull- Since:
- 3.0.0
- See Also:
just(Object),empty()
-
fromCompletionStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Maybe<@NonNull T> fromCompletionStage(@NonNull @NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)
Signals the completion value or error of the given (hot)CompletionStage-based asynchronous calculation.
Note that the operator takes an already instantiated, running or terminated
CompletionStage. If theCompletionStageis to be created per consumer upon subscription, usedefer(Supplier)aroundfromCompletionStage:Maybe.defer(() -> Maybe.fromCompletionStage(createCompletionStage()));If the
CompletionStagecompletes withnull, the resultingMaybeis completed viaonComplete.Canceling the flow can't cancel the execution of the
CompletionStagebecauseCompletionStageitself doesn't support cancellation. Instead, the operator detaches from theCompletionStage.- Scheduler:
fromCompletionStagedoes not operate by default on a particularScheduler.
- Type Parameters:
T- the element type of theCompletionStage- Parameters:
stage- theCompletionStageto convert toMaybeand signal its terminal value or error- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifstageisnull- Since:
- 3.0.0
-
mapOptional
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Maybe<R> mapOptional(@NonNull @NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)
Maps the upstream success value into anOptionaland emits the contained item if not empty.
- Scheduler:
mapOptionaldoes not operate by default on a particularScheduler.
- Type Parameters:
R- the non-nulloutput type- Parameters:
mapper- the function that receives the upstream success item and should return a non-emptyOptionalto emit as the success output or an emptyOptionalto complete theMaybe- Returns:
- the new
Maybeinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 3.0.0
- See Also:
map(Function),filter(Predicate)
-
toCompletionStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> toCompletionStage()
Signals the upstream success item (or aNoSuchElementExceptionif the upstream is empty) via aCompletionStage.
The upstream can be canceled by converting the resulting
CompletionStageintoCompletableFutureviaCompletionStage.toCompletableFuture()and callingCompletableFuture.cancel(boolean)on it. The upstream will be also cancelled if the resultingCompletionStageis converted to and completed manually byCompletableFuture.complete(Object)orCompletableFuture.completeExceptionally(Throwable).CompletionStages don't have a notion of emptiness and allownulls, therefore, one can either usetoCompletionStage(Object)withnullor turn the upstream into a sequence ofOptionals and default toOptional.empty():CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());- Scheduler:
toCompletionStagedoes not operate by default on a particularScheduler.
- Returns:
- the new
CompletionStageinstance - Since:
- 3.0.0
- See Also:
toCompletionStage(Object)
-
toCompletionStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> toCompletionStage(@Nullable @NonNull T defaultItem)
Signals the upstream success item (or the default item if the upstream is empty) via aCompletionStage.
The upstream can be canceled by converting the resulting
CompletionStageintoCompletableFutureviaCompletionStage.toCompletableFuture()and callingCompletableFuture.cancel(boolean)on it. The upstream will be also cancelled if the resultingCompletionStageis converted to and completed manually byCompletableFuture.complete(Object)orCompletableFuture.completeExceptionally(Throwable).CompletionStages don't have a notion of emptiness and allownulls, therefore, one can either use adefaultItemofnullor turn the flow into a sequence ofOptionals and default toOptional.empty():CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());- Scheduler:
toCompletionStagedoes not operate by default on a particularScheduler.
- Parameters:
defaultItem- the item to signal if the upstream is empty- Returns:
- the new
CompletionStageinstance - Since:
- 3.0.0
-
flattenStreamAsFlowable
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @NonNull public final <@NonNull R> @NonNull Flowable<R> flattenStreamAsFlowable(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps the upstream succecss value into a JavaStreamand emits its items to the downstream consumer as aFlowable.
The operator closes the
Streamupon cancellation and when it terminates. The exceptions raised when closing aStreamare routed to the global error handler (RxJavaPlugins.onError(Throwable). If aStreamshould not be closed, turn it into anIterableand useflattenAsFlowable(Function):source.flattenAsFlowable(item -> createStream(item)::iterator);Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()):source.flattenStreamAsFlowable(item -> IntStream.rangeClosed(1, 10).boxed());Streamdoes not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Backpressure:
- The operator honors backpressure from downstream and iterates the given
Streamon demand (i.e., when requested). - Scheduler:
flattenStreamAsFlowabledoes not operate by default on a particularScheduler.
- Type Parameters:
R- the element type of theStreamand the outputFlowable- Parameters:
mapper- the function that receives the upstream success item and should return aStreamof values to emit.- Returns:
- the new
Flowableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 3.0.0
- See Also:
flattenAsFlowable(Function),flattenStreamAsObservable(Function)
-
flattenStreamAsObservable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flattenStreamAsObservable(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps the upstream succecss value into a JavaStreamand emits its items to the downstream consumer as anObservable.
The operator closes the
Streamupon cancellation and when it terminates. The exceptions raised when closing aStreamare routed to the global error handler (RxJavaPlugins.onError(Throwable). If aStreamshould not be closed, turn it into anIterableand useflattenAsObservable(Function):source.flattenAsObservable(item -> createStream(item)::iterator);Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()):source.flattenStreamAsObservable(item -> IntStream.rangeClosed(1, 10).boxed());Streamdoes not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Scheduler:
flattenStreamAsObservabledoes not operate by default on a particularScheduler.
- Type Parameters:
R- the element type of theStreamand the outputObservable- Parameters:
mapper- the function that receives the upstream success item and should return aStreamof values to emit.- Returns:
- the new
Observableinstance - Throws:
java.lang.NullPointerException- ifmapperisnull- Since:
- 3.0.0
- See Also:
flattenAsObservable(Function),flattenStreamAsFlowable(Function)
-
-