signature:
public class Maybe { /** * Returns a Single that emits a Boolean value that indicates whether two MaybeSources are the
 * same by comparing the items emitted by each MaybeSource pairwise based on the results of a specified
 * equality function .
 * < img width = " 640 " height = " 385 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code sequenceEqual } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param source1
 * the first MaybeSource to compare
 * @ param source2
 * the second MaybeSource to compare
 * @ param isEqual
 * a function used to compare items emitted by each MaybeSource
 * @ param < T >
 * the type of items emitted by each MaybeSource
 * @ return a Single that emits a Boolean value that indicates whether the two MaybeSource sequences
 * are the same according to the specified function
 * @ see < a href = " http : / / reactivex . io / documentation / operators / sequenceequal . html " > ReactiveX operators documentation : SequenceEqual < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( MaybeSource < ? extends T > source1 , MaybeSource < ? extends T > source2 , BiPredicate < ? super T , ? super T > isEqual ) { } }

implementation: ObjectHelper . requireNonNull ( source1 , "source1 is null" ) ; ObjectHelper . requireNonNull ( source2 , "source2 is null" ) ; ObjectHelper . requireNonNull ( isEqual , "isEqual is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeEqualSingle < T > ( source1 , source2 , isEqual ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits { @ code 0L } after a specified delay .
 * < img width = " 640 " height = " 200 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timer . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code timer } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param delay
 * the initial delay before emitting a single { @ code 0L }
 * @ param unit
 * time units to use for { @ code delay }
 * @ return a Maybe that emits { @ code 0L } after a specified delay
 * @ see < a href = " http : / / reactivex . io / documentation / operators / timer . html " > ReactiveX operators documentation : Timer < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Maybe < Long > timer ( long delay , TimeUnit unit ) { } }

implementation: return timer ( delay , unit , Schedulers . computation ( ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits { @ code 0L } after a specified delay on a specified Scheduler .
 * < img width = " 640 " height = " 200 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timer . s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param delay
 * the initial delay before emitting a single 0L
 * @ param unit
 * time units to use for { @ code delay }
 * @ param scheduler
 * the { @ link Scheduler } to use for scheduling the item
 * @ return a Maybe that emits { @ code 0L } after a specified delay , on a specified Scheduler
 * @ see < a href = " http : / / reactivex . io / documentation / operators / timer . html " > ReactiveX operators documentation : Timer < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Maybe < Long > timer ( long delay , TimeUnit unit , Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeTimer ( Math . max ( 0L , delay ) , unit , scheduler ) ) ;


signature:
public class Maybe { /** * < strong > Advanced use only : < / strong > creates a Maybe instance without
 * any safeguards by using a callback that is called with a MaybeObserver .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code unsafeCreate } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the value type
 * @ param onSubscribe the function that is called with the subscribing MaybeObserver
 * @ return the new Maybe instance */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Maybe < T > unsafeCreate ( MaybeSource < T > onSubscribe ) { } }

implementation: if ( onSubscribe instanceof Maybe ) { throw new IllegalArgumentException ( "unsafeCreate(Maybe) should be upgraded" ) ; } ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeUnsafeCreate < T > ( onSubscribe ) ) ;


signature:
public class Maybe { /** * Constructs a Maybe that creates a dependent resource object which is disposed of when the
 * upstream terminates or the downstream calls dispose ( ) .
 * < img width = " 640 " height = " 400 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / using . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code using } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the element type of the generated MaybeSource
 * @ param < D > the type of the resource associated with the output sequence
 * @ param resourceSupplier
 * the factory function to create a resource object that depends on the Maybe
 * @ param sourceSupplier
 * the factory function to create a MaybeSource
 * @ param resourceDisposer
 * the function that will dispose of the resource
 * @ return the Maybe whose lifetime controls the lifetime of the dependent resource object
 * @ see < a href = " http : / / reactivex . io / documentation / operators / using . html " > ReactiveX operators documentation : Using < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , D > Maybe < T > using ( Callable < ? extends D > resourceSupplier , Function < ? super D , ? extends MaybeSource < ? extends T > > sourceSupplier , Consumer < ? super D > resourceDisposer ) { } }

implementation: return using ( resourceSupplier , sourceSupplier , resourceDisposer , true ) ;


signature:
public class Maybe { /** * Constructs a Maybe that creates a dependent resource object which is disposed of just before
 * termination if you have set { @ code disposeEagerly } to { @ code true } and a downstream dispose ( ) does not occur
 * before termination . Otherwise resource disposal will occur on call to dispose ( ) . Eager disposal is
 * particularly appropriate for a synchronous Maybe that reuses resources . { @ code disposeAction } will
 * only be called once per subscription .
 * < img width = " 640 " height = " 400 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / using . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code using } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the element type of the generated MaybeSource
 * @ param < D > the type of the resource associated with the output sequence
 * @ param resourceSupplier
 * the factory function to create a resource object that depends on the Maybe
 * @ param sourceSupplier
 * the factory function to create a MaybeSource
 * @ param resourceDisposer
 * the function that will dispose of the resource
 * @ param eager
 * if { @ code true } then disposal will happen either on a dispose ( ) call or just before emission of
 * a terminal event ( { @ code onComplete } or { @ code onError } ) .
 * @ return the Maybe whose lifetime controls the lifetime of the dependent resource object
 * @ see < a href = " http : / / reactivex . io / documentation / operators / using . html " > ReactiveX operators documentation : Using < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , D > Maybe < T > using ( Callable < ? extends D > resourceSupplier , Function < ? super D , ? extends MaybeSource < ? extends T > > sourceSupplier , Consumer < ? super D > resourceDisposer , boolean eager ) { } }

implementation: ObjectHelper . requireNonNull ( resourceSupplier , "resourceSupplier is null" ) ; ObjectHelper . requireNonNull ( sourceSupplier , "sourceSupplier is null" ) ; ObjectHelper . requireNonNull ( resourceDisposer , "disposer is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeUsing < T , D > ( resourceSupplier , sourceSupplier , resourceDisposer , eager ) ) ;


signature:
public class Maybe { /** * Wraps a MaybeSource instance into a new Maybe instance if not already a Maybe
 * instance .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code wrap } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the value type
 * @ param source the source to wrap
 * @ return the Maybe wrapper or the source cast to Maybe ( if possible ) */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Maybe < T > wrap ( MaybeSource < T > source ) { } }

implementation: if ( source instanceof Maybe ) { return RxJavaPlugins . onAssembly ( ( Maybe < T > ) source ) ; } ObjectHelper . requireNonNull ( source , "onSubscribe is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeUnsafeCreate < T > ( source ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the results of a specified combiner function applied to combinations of
 * items emitted , in sequence , by an Iterable of other MaybeSources .
 * Note on method signature : since Java doesn ' t allow creating a generic array with { @ code new T [ ] } , the
 * implementation of this operator has to create an { @ code Object [ ] } instead . Unfortunately , a
 * { @ code Function < Integer [ ] , R > } passed to the method would trigger a { @ code ClassCastException } .
 * < img width = " 640 " height = " 380 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / zip . png " alt = " " >
 * < p > This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete . This
 * also means it is possible some sources may not get subscribed to at all .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code zip } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the common value type
 * @ param < R > the zipped result type
 * @ param sources
 * an Iterable of source MaybeSources
 * @ param zipper
 * a function that , when applied to an item emitted by each of the source MaybeSources , results in
 * an item that will be emitted by the resulting Maybe
 * @ return a Maybe that emits the zipped results
 * @ see < a href = " http : / / reactivex . io / documentation / operators / zip . html " > ReactiveX operators documentation : Zip < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Maybe < R > zip ( Iterable < ? extends MaybeSource < ? extends T > > sources , Function < ? super Object [ ] , ? extends R > zipper ) { } }

implementation: ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeZipIterable < T , R > ( sources , zipper ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the results of a specified combiner function applied to combinations of
 * items emitted , in sequence , by an array of other MaybeSources .
 * Note on method signature : since Java doesn ' t allow creating a generic array with { @ code new T [ ] } , the
 * implementation of this operator has to create an { @ code Object [ ] } instead . Unfortunately , a
 * { @ code Function < Integer [ ] , R > } passed to the method would trigger a { @ code ClassCastException } .
 * < img width = " 640 " height = " 380 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / zip . png " alt = " " >
 * < p > This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete . This
 * also means it is possible some sources may not get subscribed to at all .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code zipArray } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < T > the common element type
 * @ param < R > the result type
 * @ param sources
 * an array of source MaybeSources
 * @ param zipper
 * a function that , when applied to an item emitted by each of the source MaybeSources , results in
 * an item that will be emitted by the resulting MaybeSource
 * @ return a Maybe that emits the zipped results
 * @ see < a href = " http : / / reactivex . io / documentation / operators / zip . html " > ReactiveX operators documentation : Zip < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Maybe < R > zipArray ( Function < ? super Object [ ] , ? extends R > zipper , MaybeSource < ? extends T > ... sources ) { } }

implementation: ObjectHelper . requireNonNull ( sources , "sources is null" ) ; if ( sources . length == 0 ) { return empty ( ) ; } ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeZipArray < T , R > ( sources , zipper ) ) ;


signature:
public class Maybe { /** * Mirrors the MaybeSource ( current or provided ) that first signals an event .
 * < img width = " 640 " height = " 385 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / amb . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code ambWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * a MaybeSource competing to react first . A subscription to this provided source will occur after
 * subscribing to the current source .
 * @ return a Maybe that emits the same sequence as whichever of the source MaybeSources first
 * signalled
 * @ see < a href = " http : / / reactivex . io / documentation / operators / amb . html " > ReactiveX operators documentation : Amb < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > ambWith ( MaybeSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return ambArray ( this , other ) ;


signature:
public class Maybe { /** * Waits in a blocking fashion until the current Maybe signals a success value ( which is returned ) ,
 * null if completed or an exception ( which is propagated ) .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code blockingGet } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < dt > < b > Error handling : < / b > < / dt >
 * < dd > If the source signals an error , the operator wraps a checked { @ link Exception }
 * into { @ link RuntimeException } and throws that . Otherwise , { @ code RuntimeException } s and
 * { @ link Error } s are rethrown as they are . < / dd >
 * < / dl >
 * @ return the success value */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingGet ( ) { } }

implementation: BlockingMultiObserver < T > observer = new BlockingMultiObserver < T > ( ) ; subscribe ( observer ) ; return observer . blockingGet ( ) ;


signature:
public class Maybe { /** * Waits in a blocking fashion until the current Maybe signals a success value ( which is returned ) ,
 * defaultValue if completed or an exception ( which is propagated ) .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code blockingGet } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < dt > < b > Error handling : < / b > < / dt >
 * < dd > If the source signals an error , the operator wraps a checked { @ link Exception }
 * into { @ link RuntimeException } and throws that . Otherwise , { @ code RuntimeException } s and
 * { @ link Error } s are rethrown as they are . < / dd >
 * < / dl >
 * @ param defaultValue the default item to return if this Maybe is empty
 * @ return the success value */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingGet ( T defaultValue ) { } }

implementation: ObjectHelper . requireNonNull ( defaultValue , "defaultValue is null" ) ; BlockingMultiObserver < T > observer = new BlockingMultiObserver < T > ( ) ; subscribe ( observer ) ; return observer . blockingGet ( defaultValue ) ;


signature:
public class Maybe { /** * Returns a Maybe that subscribes to this Maybe lazily , caches its event
 * and replays it , to all the downstream subscribers .
 * < img width = " 640 " height = " 410 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / cache . png " alt = " " >
 * The operator subscribes only when the first downstream subscriber subscribes and maintains
 * a single subscription towards this Maybe .
 * < em > Note : < / em > You sacrifice the ability to dispose the origin when you use the { @ code cache } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code cache } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a Maybe that , when first subscribed to , caches all of its items and notifications for the
 * benefit of subsequent subscribers
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > cache ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeCache < T > ( this ) ) ;


signature:
public class Maybe { /** * Transform a Maybe by applying a particular Transformer function to it .
 * This method operates on the Maybe itself whereas { @ link # lift } operates on the Maybe ' s MaybeObservers .
 * If the operator you are creating is designed to act on the individual item emitted by a Maybe , use
 * { @ link # lift } . If your operator is designed to transform the source Maybe as a whole ( for instance , by
 * applying a particular set of existing RxJava operators to it ) use { @ code compose } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code compose } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the value type of the Maybe returned by the transformer function
 * @ param transformer the transformer function , not null
 * @ return a Maybe , transformed by the transformer function
 * @ see < a href = " https : / / github . com / ReactiveX / RxJava / wiki / Implementing - Your - Own - Operators " > RxJava wiki : Implementing Your Own Operators < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Maybe < R > compose ( MaybeTransformer < ? super T , ? extends R > transformer ) { } }

implementation: return wrap ( ( ( MaybeTransformer < T , R > ) ObjectHelper . requireNonNull ( transformer , "transformer is null" ) ) . apply ( this ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe ,
 * where that function returns a MaybeSource .
 * < img width = " 640 " height = " 356 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Maybe . flatMap . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code concatMap } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * < p > Note that flatMap and concatMap for Maybe is the same operation .
 * @ param < R > the result value type
 * @ param mapper
 * a function that , when applied to the item emitted by the source Maybe , returns a MaybeSource
 * @ return the Maybe returned from { @ code func } when applied to the item emitted by the source Maybe
 * @ see < a href = " http : / / reactivex . io / documentation / operators / flatmap . html " > ReactiveX operators documentation : FlatMap < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Maybe < R > concatMap ( Function < ? super T , ? extends MaybeSource < ? extends R > > mapper ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeFlatten < T , R > ( this , mapper ) ) ;


signature:
public class Maybe { /** * Returns a Flowable that emits the items emitted from the current MaybeSource , then the next , one after
 * the other , without interleaving them .
 * < img width = " 640 " height = " 380 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concat . png " alt = " " >
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > The operator honors backpressure from downstream . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code concatWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * a MaybeSource to be concatenated after the current
 * @ return a Flowable that emits items emitted by the two source MaybeSources , one after the other ,
 * without interleaving them
 * @ see < a href = " http : / / reactivex . io / documentation / operators / concat . html " > ReactiveX operators documentation : Concat < / a > */
@ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > concatWith ( MaybeSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return concat ( this , other ) ;


signature:
public class Maybe { /** * Returns a Single that emits a Boolean that indicates whether the source Maybe emitted a
 * specified item .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / contains . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code contains } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param item
 * the item to search for in the emissions from the source Maybe , not null
 * @ return a Single that emits { @ code true } if the specified item is emitted by the source Maybe ,
 * or { @ code false } if the source Maybe completes without emitting that item
 * @ see < a href = " http : / / reactivex . io / documentation / operators / contains . html " > ReactiveX operators documentation : Contains < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Boolean > contains ( final Object item ) { } }

implementation: ObjectHelper . requireNonNull ( item , "item is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeContains < T > ( this , item ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that counts the total number of items emitted ( 0 or 1 ) by the source Maybe and emits
 * this count as a 64 - bit Long .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / longCount . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code count } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a Single that emits a single item : the number of items emitted by the source Maybe as a
 * 64 - bit Long item
 * @ see < a href = " http : / / reactivex . io / documentation / operators / count . html " > ReactiveX operators documentation : Count < / a >
 * @ see # count ( ) */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Long > count ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeCount < T > ( this ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a
 * specified delay .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / delay . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code delay } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param delay
 * the delay to shift the source by
 * @ param unit
 * the { @ link TimeUnit } in which { @ code period } is defined
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / delay . html " > ReactiveX operators documentation : Delay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Maybe < T > delay ( long delay , TimeUnit unit ) { } }

implementation: return delay ( delay , unit , Schedulers . computation ( ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that signals the events emitted by the source Maybe shifted forward in time by a
 * specified delay running on the specified Scheduler .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / delay . s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > you specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param delay
 * the delay to shift the source by
 * @ param unit
 * the time unit of { @ code delay }
 * @ param scheduler
 * the { @ link Scheduler } to use for delaying
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / delay . html " > ReactiveX operators documentation : Delay < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Maybe < T > delay ( long delay , TimeUnit unit , Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeDelay < T > ( this , Math . max ( 0L , delay ) , unit , scheduler ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that delays the subscription to this Maybe
 * until the other Publisher emits an element or completes normally .
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > The { @ code Publisher } source is consumed in an unbounded fashion ( without applying backpressure ) . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This method does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the value type of the other Publisher , irrelevant
 * @ param subscriptionIndicator the other Publisher that should trigger the subscription
 * to this Publisher .
 * @ return a Maybe that delays the subscription to this Maybe
 * until the other Publisher emits an element or completes normally . */
@ BackpressureSupport ( BackpressureKind . UNBOUNDED_IN ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Maybe < T > delaySubscription ( Publisher < U > subscriptionIndicator ) { } }

implementation: ObjectHelper . requireNonNull ( subscriptionIndicator , "subscriptionIndicator is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeDelaySubscriptionOtherPublisher < T , U > ( this , subscriptionIndicator ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that delays the subscription to the source Maybe by a given amount of time ,
 * both waiting and subscribing on a given Scheduler .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / delaySubscription . s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param delay
 * the time to delay the subscription
 * @ param unit
 * the time unit of { @ code delay }
 * @ param scheduler
 * the Scheduler on which the waiting and subscription will happen
 * @ return a Maybe that delays the subscription to the source Maybe by a given
 * amount , waiting and subscribing on the given Scheduler
 * @ see < a href = " http : / / reactivex . io / documentation / operators / delay . html " > ReactiveX operators documentation : Delay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Maybe < T > delaySubscription ( long delay , TimeUnit unit , Scheduler scheduler ) { } }

implementation: return delaySubscription ( Flowable . timer ( delay , unit , scheduler ) ) ;


signature:
public class Maybe { /** * Calls the shared consumer with the error sent via onError for each
 * MaybeObserver that subscribes to the current Maybe .
 * < img width = " 640 " height = " 358 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / doOnError . m . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code doOnError } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onError the consumer called with the success value of onError
 * @ return the new Maybe instance */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > doOnError ( Consumer < ? super Throwable > onError ) { } }

implementation:
return RxJavaPlugins . onAssembly ( new MaybePeek < T > ( this , Functions . emptyConsumer ( ) , // onSubscribe
Functions . emptyConsumer ( ) , // onSuccess
ObjectHelper . requireNonNull ( onError , "onError is null" ) , Functions . EMPTY_ACTION , // onComplete
Functions . EMPTY_ACTION , // ( onSuccess | onError | onComplete )
Functions . EMPTY_ACTION // dispose
) ) ;


signature:
public class Maybe { /** * Calls the given onEvent callback with the ( success value , null ) for an onSuccess , ( null , throwable ) for
 * an onError or ( null , null ) for an onComplete signal from this Maybe before delivering said
 * signal to the downstream .
 * Exceptions thrown from the callback will override the event so the downstream receives the
 * error instead of the original signal .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code doOnEvent } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onEvent the callback to call with the terminal event tuple
 * @ return the new Maybe instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > doOnEvent ( BiConsumer < ? super T , ? super Throwable > onEvent ) { } }

implementation: ObjectHelper . requireNonNull ( onEvent , "onEvent is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeDoOnEvent < T > ( this , onEvent ) ) ;


signature:
public class Maybe { /** * Returns a Maybe instance that calls the given onTerminate callback
 * just before this Maybe completes normally or with an exception .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / doOnTerminate . png " alt = " " >
 * This differs from { @ code doAfterTerminate } in that this happens < em > before < / em > the { @ code onComplete } or
 * { @ code onError } notification .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code doOnTerminate } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onTerminate the action to invoke when the consumer calls { @ code onComplete } or { @ code onError }
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / do . html " > ReactiveX operators documentation : Do < / a >
 * @ see # doOnTerminate ( Action )
 * @ since 2.2.7 - experimental */
@ Experimental @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > doOnTerminate ( final Action onTerminate ) { } }

implementation: ObjectHelper . requireNonNull ( onTerminate , "onTerminate is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeDoOnTerminate < T > ( this , onTerminate ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the results of a specified function to the pair of values emitted by the
 * source Maybe and a specified mapped MaybeSource .
 * < img width = " 640 " height = " 390 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / mergeMap . r . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code flatMap } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U >
 * the type of items emitted by the MaybeSource returned by the { @ code mapper } function
 * @ param < R >
 * the type of items emitted by the resulting Maybe
 * @ param mapper
 * a function that returns a MaybeSource for the item emitted by the source Maybe
 * @ param resultSelector
 * a function that combines one item emitted by each of the source and collection MaybeSource and
 * returns an item to be emitted by the resulting MaybeSource
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / flatmap . html " > ReactiveX operators documentation : FlatMap < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U , R > Maybe < R > flatMap ( Function < ? super T , ? extends MaybeSource < ? extends U > > mapper , BiFunction < ? super T , ? super U , ? extends R > resultSelector ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; ObjectHelper . requireNonNull ( resultSelector , "resultSelector is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeFlatMapBiSelector < T , U , R > ( this , mapper , resultSelector ) ) ;


signature:
public class Maybe { /** * Maps the success value of the upstream { @ link Maybe } into an { @ link Iterable } and emits its items as a
 * { @ link Flowable } sequence .
 * < img width = " 640 " height = " 373 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / flattenAsFlowable . png " alt = " " >
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > The operator honors backpressure from downstream . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code flattenAsFlowable } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U >
 * the type of item emitted by the resulting Iterable
 * @ param mapper
 * a function that returns an Iterable sequence of values for when given an item emitted by the
 * source Maybe
 * @ return the new Flowable instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / flatmap . html " > ReactiveX operators documentation : FlatMap < / a > */
@ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Flowable < U > flattenAsFlowable ( final Function < ? super T , ? extends Iterable < ? extends U > > mapper ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeFlatMapIterableFlowable < T , U > ( this , mapper ) ) ;


signature:
public class Maybe { /** * Hides the identity of this Maybe and its Disposable .
 * < img width = " 640 " height = " 300 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Maybe . hide . png " alt = " " >
 * < p > Allows preventing certain identity - based
 * optimizations ( fusion ) .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code hide } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the new Maybe instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > hide ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeHide < T > ( this ) ) ;


signature:
public class Maybe { /** * Ignores the item emitted by the source Maybe and only calls { @ code onComplete } or { @ code onError } .
 * < img width = " 640 " height = " 389 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Maybe . ignoreElement . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code ignoreElement } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return an empty Completable that only calls { @ code onComplete } or { @ code onError } , based on which one is
 * called by the source Maybe
 * @ see < a href = " http : / / reactivex . io / documentation / operators / ignoreelements . html " > ReactiveX operators documentation : IgnoreElements < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Completable ignoreElement ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeIgnoreElementCompletable < T > ( this ) ) ;


signature:
public class Maybe { /** * Returns a Single that emits { @ code true } if the source Maybe is empty , otherwise { @ code false } .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / isEmpty . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code isEmpty } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a Single that emits a Boolean
 * @ see < a href = " http : / / reactivex . io / documentation / operators / contains . html " > ReactiveX operators documentation : Contains < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Boolean > isEmpty ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeIsEmptySingle < T > ( this ) ) ;


signature:
public class Maybe { /** * < strong > This method requires advanced knowledge about building operators , please consider
 * other standard composition methods first ; < / strong >
 * Returns a { @ code Maybe } which , when subscribed to , invokes the { @ link MaybeOperator # apply ( MaybeObserver ) apply ( MaybeObserver ) } method
 * of the provided { @ link MaybeOperator } for each individual downstream { @ link Maybe } and allows the
 * insertion of a custom operator by accessing the downstream ' s { @ link MaybeObserver } during this subscription phase
 * and providing a new { @ code MaybeObserver } , containing the custom operator ' s intended business logic , that will be
 * used in the subscription process going further upstream .
 * Generally , such a new { @ code MaybeObserver } will wrap the downstream ' s { @ code MaybeObserver } and forwards the
 * { @ code onSuccess } , { @ code onError } and { @ code onComplete } events 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 of { @ code dispose } and { @ code isDisposed } that would have traveled upstream and perform
 * additional actions depending on the same business logic requirements .
 * Example :
 * < pre > < code >
 * / / Step 1 : Create the consumer type that will be returned by the MaybeOperator . apply ( ) :
 * public final class CustomMaybeObserver & lt ; T & gt ; implements MaybeObserver & lt ; T & gt ; , Disposable {
 * / / The downstream ' s MaybeObserver that will receive the onXXX events
 * final MaybeObserver & lt ; ? super String & gt ; 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 & lt ; ? super String & gt ; 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
 * & # 64 ; 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
 * & # 64 ; Override
 * public void onSuccess ( T item ) {
 * String str = item . toString ( ) ;
 * if ( str . length ( ) & lt ; 2 ) {
 * downstream . onSuccess ( str ) ;
 * } else {
 * / / Maybe is usually expected to produce one of the onXXX events
 * downstream . onComplete ( ) ;
 * / / Some operators may handle the upstream ' s error while others
 * / / could just forward it to the downstream .
 * & # 64 ; Override
 * public void onError ( Throwable throwable ) {
 * downstream . onError ( throwable ) ;
 * / / When the upstream completes , usually the downstream should complete as well .
 * & # 64 ; 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 .
 * & # 64 ; 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 ( ) .
 * & # 64 ; 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 & lt ; T & gt ; implements MaybeOperator & lt ; String & gt ; {
 * & # 64 ; Override
 * public MaybeObserver & lt ; ? super String & gt ; apply ( MaybeObserver & lt ; ? super T & gt ; upstream ) {
 * return new CustomMaybeObserver & lt ; T & gt ; ( 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 & lt ; Integer & gt ; ( ) )
 * . test ( )
 * . assertResult ( " 5 " ) ;
 * Maybe . just ( 15)
 * . lift ( new CustomMaybeOperator & lt ; Integer & gt ; ( ) )
 * . test ( )
 * . assertResult ( ) ;
 * < / code > < / pre >
 * Creating custom operators can be complicated and it is recommended one consults the
 * < a href = " https : / / github . com / ReactiveX / RxJava / wiki / Writing - operators - for - 2.0 " > RxJava wiki : Writing operators < / a > page about
 * the tools , requirements , rules , considerations and pitfalls of implementing them .
 * Note that implementing custom operators via this { @ code lift ( ) } method adds slightly more overhead by requiring
 * an additional allocation and indirection per assembled flows . Instead , extending the abstract { @ code Maybe }
 * class and creating a { @ link MaybeTransformer } with it is recommended .
 * Note also that it is not possible to stop the subscription phase in { @ code lift ( ) } as the { @ code apply ( ) } method
 * requires a non - null { @ code MaybeObserver } instance to be returned , which is then unconditionally subscribed to
 * the upstream { @ code Maybe } . 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 a { @ code MaybeObserver } that should immediately dispose the upstream ' s { @ code Disposable } in its
 * { @ code onSubscribe } method . Again , using a { @ code MaybeTransformer } and extending the { @ code Maybe } is
 * a better option as { @ link # subscribeActual } can decide to not subscribe to its upstream after all .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code lift } does not operate by default on a particular { @ link Scheduler } , however , the
 * { @ link MaybeOperator } may use a { @ code Scheduler } to support its own asynchronous behavior . < / dd >
 * < / dl >
 * @ param < R > the output value type
 * @ param lift the { @ link MaybeOperator } that receives the downstream ' s { @ code MaybeObserver } and should return
 * a { @ code MaybeObserver } with custom behavior to be used as the consumer for the current
 * { @ code Maybe } .
 * @ return the new Maybe instance
 * @ see < a href = " https : / / github . com / ReactiveX / RxJava / wiki / Writing - operators - for - 2.0 " > RxJava wiki : Writing operators < / a >
 * @ see # compose ( MaybeTransformer ) */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Maybe < R > lift ( final MaybeOperator < ? extends R , ? super T > lift ) { } }

implementation: ObjectHelper . requireNonNull ( lift , "lift is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeLift < T , R > ( this , lift ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that applies a specified function to the item emitted by the source Maybe and
 * emits the result of this function application .
 * < img width = " 640 " height = " 515 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Maybe . map . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code map } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the result value type
 * @ param mapper
 * a function to apply to the item emitted by the Maybe
 * @ return a Maybe that emits the item from the source Maybe , transformed by the specified function
 * @ see < a href = " http : / / reactivex . io / documentation / operators / map . html " > ReactiveX operators documentation : Map < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Maybe < R > map ( Function < ? super T , ? extends R > mapper ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeMap < T , R > ( this , mapper ) ) ;


signature:
public class Maybe { /** * Filters the items emitted by a Maybe , only emitting its success value if that
 * is an instance of the supplied Class .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / ofClass . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code ofType } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the output type
 * @ param clazz
 * the class type to filter the items emitted by the source Maybe
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / filter . html " > ReactiveX operators documentation : Filter < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Maybe < U > ofType ( final Class < U > clazz ) { } }

implementation: ObjectHelper . requireNonNull ( clazz , "clazz is null" ) ; return filter ( Functions . isInstanceOf ( clazz ) ) . cast ( clazz ) ;


signature:
public class Maybe { /** * Calls the specified converter function with the current Maybe instance
 * during assembly time and returns its result .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code to } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the result type
 * @ param convert the function that is called with the current Maybe instance during
 * assembly time that should return some value to be the result
 * @ return the value returned by the convert function */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > R to ( Function < ? super Maybe < T > , R > convert ) { } }

implementation: try { return ObjectHelper . requireNonNull ( convert , "convert is null" ) . apply ( this ) ; } catch ( Throwable ex ) { Exceptions . throwIfFatal ( ex ) ; throw ExceptionHelper . wrapOrThrow ( ex ) ; }


signature:
public class Maybe { /** * Converts this Maybe into an Observable instance composing disposal
 * through .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code toObservable } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the new Observable instance */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > toObservable ( ) { } }

implementation: if ( this instanceof FuseToObservable ) { return ( ( FuseToObservable < T > ) this ) . fuseToObservable ( ) ; } return RxJavaPlugins . onAssembly ( new MaybeToObservable < T > ( this ) ) ;


signature:
public class Maybe { /** * Converts this Maybe into a Single instance composing disposal
 * through and turning an empty Maybe into a signal of NoSuchElementException .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code toSingle } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the new Single instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > toSingle ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeToSingle < T > ( this , null ) ) ;


signature:
public class Maybe { /** * Returns a Maybe instance that if this Maybe emits an error , it will emit an onComplete
 * and swallow the throwable .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onErrorComplete } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the new Maybe instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > onErrorComplete ( ) { } }

implementation: return onErrorComplete ( Functions . alwaysTrue ( ) ) ;


signature:
public class Maybe { /** * Instructs a Maybe to pass control to another { @ link MaybeSource } rather than invoking
 * { @ link MaybeObserver # onError onError } if it encounters an error .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onErrorResumeNext . png " alt = " " >
 * You can use this to prevent errors from propagating or to supply fallback data should errors be
 * encountered .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onErrorResumeNext } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param next
 * the next { @ code MaybeSource } that will take over if the source Maybe encounters
 * an error
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / catch . html " > ReactiveX operators documentation : Catch < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > onErrorResumeNext ( final MaybeSource < ? extends T > next ) { } }

implementation: ObjectHelper . requireNonNull ( next , "next is null" ) ; return onErrorResumeNext ( Functions . justFunction ( next ) ) ;


signature:
public class Maybe { /** * Instructs a Maybe to pass control to another Maybe rather than invoking
 * { @ link MaybeObserver # onError onError } if it encounters an error .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onErrorResumeNext . png " alt = " " >
 * You can use this to prevent errors from propagating or to supply fallback data should errors be
 * encountered .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onErrorResumeNext } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param resumeFunction
 * a function that returns a MaybeSource that will take over if the source Maybe encounters
 * an error
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / catch . html " > ReactiveX operators documentation : Catch < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > onErrorResumeNext ( Function < ? super Throwable , ? extends MaybeSource < ? extends T > > resumeFunction ) { } }

implementation: ObjectHelper . requireNonNull ( resumeFunction , "resumeFunction is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeOnErrorNext < T > ( this , resumeFunction , true ) ) ;


signature:
public class Maybe { /** * Instructs a Maybe to emit an item ( returned by a specified function ) rather than invoking
 * { @ link MaybeObserver # onError onError } if it encounters an error .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onErrorReturn . png " alt = " " >
 * You can use this to prevent errors from propagating or to supply fallback data should errors be
 * encountered .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onErrorReturn } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param valueSupplier
 * a function that returns a single value that will be emitted as success value
 * the current Maybe signals an onError event
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / catch . html " > ReactiveX operators documentation : Catch < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > onErrorReturn ( Function < ? super Throwable , ? extends T > valueSupplier ) { } }

implementation: ObjectHelper . requireNonNull ( valueSupplier , "valueSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeOnErrorReturn < T > ( this , valueSupplier ) ) ;


signature:
public class Maybe { /** * Nulls out references to the upstream producer and downstream MaybeObserver if
 * the sequence is terminated or downstream calls dispose ( ) .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onTerminateDetach } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a Maybe which nulls out references to the upstream producer and downstream MaybeObserver if
 * the sequence is terminated or downstream calls dispose ( ) */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > onTerminateDetach ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new MaybeDetach < T > ( this ) ) ;


signature:
public class Maybe { /** * Returns a Flowable that repeats the sequence of items emitted by the source Maybe until
 * the provided stop function returns true .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeat . on . png " alt = " " >
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > This operator honors downstream backpressure . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeatUntil } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param stop
 * a boolean supplier that is called when the current Flowable completes and unless it returns
 * false , the current Flowable is resubscribed
 * @ return the new Flowable instance
 * @ throws NullPointerException
 * if { @ code stop } is null
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > repeatUntil ( BooleanSupplier stop ) { } }

implementation: return toFlowable ( ) . repeatUntil ( stop ) ;


signature:
public class Maybe { /** * Returns a Flowable that emits the same values as the source Publisher with the exception of an
 * { @ code onComplete } . An { @ code onComplete } notification from the source will result in the emission of
 * a { @ code void } item to the Publisher provided as an argument to the { @ code notificationHandler }
 * function . If that Publisher calls { @ code onComplete } or { @ code onError } then { @ code repeatWhen } will
 * call { @ code onComplete } or { @ code onError } on the child subscription . Otherwise , this Publisher will
 * resubscribe to the source Publisher .
 * < img width = " 640 " height = " 430 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeatWhen . f . png " alt = " " >
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > The operator honors downstream backpressure and expects the source { @ code Publisher } to honor backpressure as well .
 * If this expectation is violated , the operator < em > may < / em > throw an { @ code IllegalStateException } . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeatWhen } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param handler
 * receives a Publisher of notifications with which a user can complete or error , aborting the repeat .
 * @ return the source Publisher modified with repeat logic
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > repeatWhen ( final Function < ? super Flowable < Object > , ? extends Publisher < ? > > handler ) { } }

implementation: return toFlowable ( ) . repeatWhen ( handler ) ;


signature:
public class Maybe { /** * Returns a Maybe that mirrors the source Maybe , resubscribing to it if it calls { @ code onError }
 * and the predicate returns true for that specific exception and retry count .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param predicate
 * the predicate that determines if a resubscription may happen in case of a specific exception
 * and retry count
 * @ return the new Maybe instance
 * @ see # retry ( )
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > retry ( BiPredicate < ? super Integer , ? super Throwable > predicate ) { } }

implementation: return toFlowable ( ) . retry ( predicate ) . singleElement ( ) ;


signature:
public class Maybe { /** * Returns a Maybe that mirrors the source Maybe , resubscribing to it if it calls { @ code onError }
 * up to a specified number of retries .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . png " alt = " " >
 * If the source Maybe calls { @ link MaybeObserver # onError } , this method will resubscribe to the source
 * Maybe for a maximum of { @ code count } resubscriptions rather than propagating the
 * { @ code onError } call .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param count
 * the number of times to resubscribe if the current Maybe fails
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > retry ( long count ) { } }

implementation: return retry ( count , Functions . alwaysTrue ( ) ) ;


signature:
public class Maybe { /** * Retries at most times or until the predicate returns false , whichever happens first .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param times the number of times to resubscribe if the current Maybe fails
 * @ param predicate the predicate called with the failure Throwable and should return true to trigger a retry .
 * @ return the new Maybe instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > retry ( long times , Predicate < ? super Throwable > predicate ) { } }

implementation: return toFlowable ( ) . retry ( times , predicate ) . singleElement ( ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the same values as the source Maybe with the exception of an
 * { @ code onError } . An { @ code onError } notification from the source will result in the emission of a
 * { @ link Throwable } item to the Publisher provided as an argument to the { @ code notificationHandler }
 * function . If that Publisher calls { @ code onComplete } or { @ code onError } then { @ code retry } will call
 * { @ code onComplete } or { @ code onError } on the child subscription . Otherwise , this Publisher will
 * resubscribe to the source Publisher .
 * < img width = " 640 " height = " 430 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retryWhen . f . png " alt = " " >
 * Example :
 * This retries 3 times , each time incrementing the number of seconds it waits .
 * < pre > < code >
 * Maybe . create ( ( MaybeEmitter & lt ; ? super String & gt ; s ) - & gt ; {
 * System . out . println ( " subscribing " ) ;
 * s . onError ( new RuntimeException ( " always fails " ) ) ;
 * } , BackpressureStrategy . BUFFER ) . retryWhen ( attempts - & gt ; {
 * return attempts . zipWith ( Publisher . range ( 1 , 3 ) , ( n , i ) - & gt ; i ) . flatMap ( i - & gt ; {
 * System . out . println ( " delay retry by " + i + " second ( s ) " ) ;
 * return Flowable . timer ( i , TimeUnit . SECONDS ) ;
 * } ) . blockingForEach ( System . out : : println ) ;
 * < / code > < / pre >
 * Output is :
 * < pre > { @ code
 * subscribing
 * delay retry by 1 second ( s )
 * subscribing
 * delay retry by 2 second ( s )
 * subscribing
 * delay retry by 3 second ( s )
 * subscribing
 * } < / pre >
 * Note that the inner { @ code Publisher } returned by the handler function should signal
 * either { @ code onNext } , { @ code onError } or { @ code onComplete } in response to the received
 * { @ code Throwable } to indicate the operator should retry or terminate . If the upstream to
 * the operator is asynchronous , signalling onNext followed by onComplete immediately may
 * result in the sequence to be completed immediately . Similarly , if this inner
 * { @ code Publisher } signals { @ code onError } or { @ code onComplete } while 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 :
 * < pre > < code >
 * Maybe . timer ( 1 , TimeUnit . SECONDS )
 * . doOnSubscribe ( s - & gt ; System . out . println ( " subscribing " ) )
 * . map ( v - & gt ; { throw new RuntimeException ( ) ; } )
 * . retryWhen ( errors - & gt ; {
 * AtomicInteger counter = new AtomicInteger ( ) ;
 * return errors
 * . takeWhile ( e - & gt ; counter . getAndIncrement ( ) ! = 3)
 * . flatMap ( e - & gt ; {
 * System . out . println ( " delay retry by " + counter . get ( ) + " second ( s ) " ) ;
 * return Flowable . timer ( counter . get ( ) , TimeUnit . SECONDS ) ;
 * . blockingGet ( ) ;
 * < / code > < / pre >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retryWhen } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param handler
 * receives a Publisher of notifications with which a user can complete or error , aborting the
 * retry
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > retryWhen ( final Function < ? super Flowable < Throwable > , ? extends Publisher < ? > > handler ) { } }

implementation: return toFlowable ( ) . retryWhen ( handler ) . singleElement ( ) ;


signature:
public class Maybe { /** * Subscribes to a Maybe and ignores { @ code onSuccess } and { @ code onComplete } emissions .
 * If the Maybe emits an error , it is wrapped into an
 * { @ link io . reactivex . exceptions . OnErrorNotImplementedException OnErrorNotImplementedException }
 * and routed to the RxJavaPlugins . onError handler .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code subscribe } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a { @ link Disposable } reference with which the caller can stop receiving items before
 * the Maybe has finished sending them
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribe . html " > ReactiveX operators documentation : Subscribe < / a > */
@ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( ) { } }

implementation: return subscribe ( Functions . emptyConsumer ( ) , Functions . ON_ERROR_MISSING , Functions . EMPTY_ACTION ) ;


signature:
public class Maybe { /** * Subscribes to a Maybe and provides callbacks to handle the items it emits and any error
 * notification it issues .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code subscribe } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onSuccess
 * the { @ code Consumer < T > } you have designed to accept a success value from the Maybe
 * @ param onError
 * the { @ code Consumer < Throwable > } you have designed to accept any error notification from the
 * Maybe
 * @ return a { @ link Disposable } reference with which the caller can stop receiving items before
 * the Maybe has finished sending them
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribe . html " > ReactiveX operators documentation : Subscribe < / a >
 * @ throws NullPointerException
 * if { @ code onSuccess } is null , or
 * if { @ code onError } is null */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( Consumer < ? super T > onSuccess , Consumer < ? super Throwable > onError ) { } }

implementation: return subscribe ( onSuccess , onError , Functions . EMPTY_ACTION ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the items emitted by the source Maybe or the items of an alternate
 * MaybeSource if the current Maybe is empty .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchifempty . m . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchIfEmpty } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * the alternate MaybeSource to subscribe to if the main does not emit any items
 * @ return a Maybe that emits the items emitted by the source Maybe or the items of an
 * alternate MaybeSource if the source Maybe is empty . */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > switchIfEmpty ( MaybeSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeSwitchIfEmpty < T > ( this , other ) ) ;


signature:
public class Maybe { /** * Returns a Single that emits the items emitted by the source Maybe or the item of an alternate
 * SingleSource if the current Maybe is empty .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchifempty . m . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchIfEmpty } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * < p > History : 2.1.4 - experimental
 * @ param other
 * the alternate SingleSource to subscribe to if the main does not emit any items
 * @ return a Single that emits the items emitted by the source Maybe or the item of an
 * alternate SingleSource if the source Maybe is empty .
 * @ since 2.2 */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > switchIfEmpty ( SingleSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeSwitchIfEmptySingle < T > ( this , other ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that emits the items emitted by the source Maybe until a second MaybeSource
 * emits an item .
 * < img width = " 640 " height = " 380 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / takeUntil . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code takeUntil } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * the MaybeSource whose first emitted item will cause { @ code takeUntil } to stop emitting items
 * from the source Maybe
 * @ param < U >
 * the type of items emitted by { @ code other }
 * @ return a Maybe that emits the items emitted by the source Maybe until such time as { @ code other } emits its first item
 * @ see < a href = " http : / / reactivex . io / documentation / operators / takeuntil . html " > ReactiveX operators documentation : TakeUntil < / a > */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Maybe < T > takeUntil ( MaybeSource < U > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeTakeUntilMaybe < T , U > ( this , other ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted
 * item . If the next item isn ' t emitted within the specified timeout duration starting from its predecessor ,
 * the resulting Maybe terminates and notifies MaybeObservers of a { @ code TimeoutException } .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timeout . 1 . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code timeout } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param timeout
 * maximum duration between emitted items before a timeout occurs
 * @ param timeUnit
 * the unit of time that applies to the { @ code timeout } argument .
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / timeout . html " > ReactiveX operators documentation : Timeout < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Maybe < T > timeout ( long timeout , TimeUnit timeUnit ) { } }

implementation: return timeout ( timeout , timeUnit , Schedulers . computation ( ) ) ;


signature:
public class Maybe { /** * Returns a Maybe that mirrors the source Maybe but applies a timeout policy for each emitted
 * item , where this policy is governed on a specified Scheduler . If the next item isn ' t emitted within the
 * specified timeout duration starting from its predecessor , the resulting Maybe terminates and
 * notifies MaybeObservers of a { @ code TimeoutException } .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timeout . 1s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param timeout
 * maximum duration between items before a timeout occurs
 * @ param timeUnit
 * the unit of time that applies to the { @ code timeout } argument
 * @ param scheduler
 * the Scheduler to run the timeout timers on
 * @ return the new Maybe instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / timeout . html " > ReactiveX operators documentation : Timeout < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Maybe < T > timeout ( long timeout , TimeUnit timeUnit , Scheduler scheduler ) { } }

implementation: return timeout ( timer ( timeout , timeUnit , scheduler ) ) ;


signature:
public class Maybe { /** * If the current { @ code Maybe } didn ' t signal an event before the { @ code timeoutIndicator } { @ link MaybeSource } signals , a
 * { @ link TimeoutException } is signaled instead .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code timeout } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the value type of the
 * @ param timeoutIndicator the { @ code MaybeSource } that indicates the timeout by signaling onSuccess
 * or onComplete .
 * @ return the new Maybe instance */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Maybe < T > timeout ( MaybeSource < U > timeoutIndicator ) { } }

implementation: ObjectHelper . requireNonNull ( timeoutIndicator , "timeoutIndicator is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeTimeoutMaybe < T , U > ( this , timeoutIndicator , null ) ) ;


signature:
public class Maybe { /** * If the current { @ code Maybe } source didn ' t signal an event before the { @ code timeoutIndicator } { @ link Publisher } signals , a
 * { @ link TimeoutException } is signaled instead .
 * < dl >
 * < dt > < b > Backpressure : < / b > < / dt >
 * < dd > The { @ code timeoutIndicator } { @ link Publisher } is consumed in an unbounded manner and
 * is cancelled after its first item . < / dd >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code timeout } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the value type of the
 * @ param timeoutIndicator the { @ code MaybeSource } that indicates the timeout by signaling { @ code onSuccess }
 * or { @ code onComplete } .
 * @ return the new Maybe instance */
@ BackpressureSupport ( BackpressureKind . UNBOUNDED_IN ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Maybe < T > timeout ( Publisher < U > timeoutIndicator ) { } }

implementation: ObjectHelper . requireNonNull ( timeoutIndicator , "timeoutIndicator is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeTimeoutPublisher < T , U > ( this , timeoutIndicator , null ) ) ;


signature:
public class Maybe { /** * Returns a Maybe which makes sure when a MaybeObserver disposes the Disposable ,
 * that call is propagated up on the specified scheduler .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code unsubscribeOn } calls dispose ( ) of the upstream on the { @ link Scheduler } you specify . < / dd >
 * < / dl >
 * @ param scheduler the target scheduler where to execute the disposal
 * @ return the new Maybe instance
 * @ throws NullPointerException if scheduler is null */
@ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Maybe < T > unsubscribeOn ( final Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new MaybeUnsubscribeOn < T > ( this , scheduler ) ) ;


signature:
public class FlowablePublish { /** * Creates a OperatorPublish instance to publish values of the given source observable .
 * @ param < T > the source value type
 * @ param source the source observable
 * @ param bufferSize the size of the prefetch buffer
 * @ return the connectable observable */
public static < T > ConnectableFlowable < T > create ( Flowable < T > source , final int bufferSize ) { } }

implementation:
// the current connection to source needs to be shared between the operator and its onSubscribe call
final AtomicReference < PublishSubscriber < T > > curr = new AtomicReference < PublishSubscriber < T > > ( ) ; Publisher < T > onSubscribe = new FlowablePublisher < T > ( curr , bufferSize ) ; return RxJavaPlugins . onAssembly ( new FlowablePublish < T > ( onSubscribe , source , curr , bufferSize ) ) ;


signature:
public class SingleToObservable { /** * Creates a { @ link SingleObserver } wrapper around a { @ link Observer } .
 * < p > History : 2.0.1 - experimental
 * @ param < T > the value type
 * @ param downstream the downstream { @ code Observer } to talk to
 * @ return the new SingleObserver instance
 * @ since 2.2 */
public static < T > SingleObserver < T > create ( Observer < ? super T > downstream ) { } }

implementation: return new SingleToObservableObserver < T > ( downstream ) ;


signature:
public class ObjectHelper { /** * Verifies if the object is not null and returns it or throws a NullPointerException
 * with the given message .
 * @ param < T > the value type
 * @ param object the object to verify
 * @ param message the message to use with the NullPointerException
 * @ return the object itself
 * @ throws NullPointerException if object is null */
public static < T > T requireNonNull ( T object , String message ) { } }

implementation: if ( object == null ) { throw new NullPointerException ( message ) ; } return object ;


signature:
public class ObjectHelper { /** * Returns a BiPredicate that compares its parameters via Objects . equals ( ) .
 * @ param < T > the value type
 * @ return the bi - predicate instance */
@ SuppressWarnings ( "unchecked" ) public static < T > BiPredicate < T , T > equalsPredicate ( ) { } }

implementation: return ( BiPredicate < T , T > ) EQUALS ;


signature:
public class HalfSerializer { /** * Emits the given exception if possible or adds it to the given error container to
 * be emitted by a concurrent onNext if one is running .
 * Undeliverable exceptions are sent to the RxJavaPlugins . onError .
 * @ param subscriber the target Subscriber to emit to
 * @ param ex the Throwable to emit
 * @ param wip the serialization work - in - progress counter / indicator
 * @ param error the holder of Throwables */
public static void onError ( Subscriber < ? > subscriber , Throwable ex , AtomicInteger wip , AtomicThrowable error ) { } }

implementation: if ( error . addThrowable ( ex ) ) { if ( wip . getAndIncrement ( ) == 0 ) { subscriber . onError ( error . terminate ( ) ) ; } } else { RxJavaPlugins . onError ( ex ) ; }


signature:
public class HalfSerializer { /** * Emits an onComplete signal or an onError signal with the given error or indicates
 * the concurrently running onNext should do that .
 * @ param subscriber the target Subscriber to emit to
 * @ param wip the serialization work - in - progress counter / indicator
 * @ param error the holder of Throwables */
public static void onComplete ( Subscriber < ? > subscriber , AtomicInteger wip , AtomicThrowable error ) { } }

implementation: if ( wip . getAndIncrement ( ) == 0 ) { Throwable ex = error . terminate ( ) ; if ( ex != null ) { subscriber . onError ( ex ) ; } else { subscriber . onComplete ( ) ; } }


signature:
public class HalfSerializer { /** * Emits the given exception if possible or adds it to the given error container to
 * be emitted by a concurrent onNext if one is running .
 * Undeliverable exceptions are sent to the RxJavaPlugins . onError .
 * @ param observer the target Subscriber to emit to
 * @ param ex the Throwable to emit
 * @ param wip the serialization work - in - progress counter / indicator
 * @ param error the holder of Throwables */
public static void onError ( Observer < ? > observer , Throwable ex , AtomicInteger wip , AtomicThrowable error ) { } }

implementation: if ( error . addThrowable ( ex ) ) { if ( wip . getAndIncrement ( ) == 0 ) { observer . onError ( error . terminate ( ) ) ; } } else { RxJavaPlugins . onError ( ex ) ; }


signature:
public class HalfSerializer { /** * Emits an onComplete signal or an onError signal with the given error or indicates
 * the concurrently running onNext should do that .
 * @ param observer the target Subscriber to emit to
 * @ param wip the serialization work - in - progress counter / indicator
 * @ param error the holder of Throwables */
public static void onComplete ( Observer < ? > observer , AtomicInteger wip , AtomicThrowable error ) { } }

implementation: if ( wip . getAndIncrement ( ) == 0 ) { Throwable ex = error . terminate ( ) ; if ( ex != null ) { observer . onError ( ex ) ; } else { observer . onComplete ( ) ; } }


signature:
public class Functions { /** * Returns an identity function that simply returns its argument .
 * @ param < T > the input and output value type
 * @ return the identity function */
@ SuppressWarnings ( "unchecked" ) public static < T > Function < T , T > identity ( ) { } }

implementation: return ( Function < T , T > ) IDENTITY ;


signature:
public class Functions { /** * Returns a Callable that returns the given value .
 * @ param < T > the value type
 * @ param value the value to return
 * @ return the new Callable instance */
public static < T > Callable < T > justCallable ( T value ) { } }

implementation: return new JustValue < Object , T > ( value ) ;


signature:
public class Functions { /** * Returns a Function that ignores its parameter and returns the given value .
 * @ param < T > the function ' s input type
 * @ param < U > the value and return type of the function
 * @ param value the value to return
 * @ return the new Function instance */
public static < T , U > Function < T , U > justFunction ( U value ) { } }

implementation: return new JustValue < T , U > ( value ) ;


signature:
public class Functions { /** * Returns a function that cast the incoming values via a Class object .
 * @ param < T > the input value type
 * @ param < U > the output and target type
 * @ param target the target class
 * @ return the new Function instance */
public static < T , U > Function < T , U > castFunction ( Class < U > target ) { } }

implementation: return new CastToClass < T , U > ( target ) ;


signature:
public class CompositeException { /** * Special handling for printing out a { @ code CompositeException } .
 * Loops through all inner exceptions and prints them out .
 * @ param s
 * stream to print to */
private void printStackTrace ( PrintStreamOrWriter s ) { } }

implementation: StringBuilder b = new StringBuilder ( 128 ) ; b . append ( this ) . append ( '\n' ) ; for ( StackTraceElement myStackElement : getStackTrace ( ) ) { b . append ( "\tat " ) . append ( myStackElement ) . append ( '\n' ) ; } int i = 1 ; for ( Throwable ex : exceptions ) { b . append ( "  ComposedException " ) . append ( i ) . append ( " :\n" ) ; appendStackTrace ( b , ex , "\t" ) ; i ++ ; } s . println ( b . toString ( ) ) ;


signature:
public class CompositeException { /** * / * private */
Throwable getRootCause ( Throwable e ) { } }

implementation: Throwable root = e . getCause ( ) ; if ( root == null || e == root ) { return e ; } while ( true ) { Throwable cause = root . getCause ( ) ; if ( cause == null || cause == root ) { return root ; } root = cause ; }


signature:
public class UnicastSubject { /** * Creates an UnicastSubject with an internal buffer capacity hint 16.
 * @ param < T > the value type
 * @ return an UnicastSubject instance */
@ CheckReturnValue @ NonNull public static < T > UnicastSubject < T > create ( ) { } }

implementation: return new UnicastSubject < T > ( bufferSize ( ) , true ) ;


signature:
public class UnicastSubject { /** * Creates an UnicastSubject with the given internal buffer capacity hint .
 * @ param < T > the value type
 * @ param capacityHint the hint to size the internal unbounded buffer
 * @ return an UnicastSubject instance */
@ CheckReturnValue @ NonNull public static < T > UnicastSubject < T > create ( int capacityHint ) { } }

implementation: return new UnicastSubject < T > ( capacityHint , true ) ;


signature:
public class UnicastSubject { /** * Creates an UnicastSubject with the given internal buffer capacity hint and a callback for
 * the case when the single Subscriber cancels its subscription .
 * < p > The callback , if not null , is called exactly once and
 * non - overlapped with any active replay .
 * @ param < T > the value type
 * @ param capacityHint the hint to size the internal unbounded buffer
 * @ param onTerminate the callback to run when the Subject is terminated or cancelled , null not allowed
 * @ return an UnicastSubject instance */
@ CheckReturnValue @ NonNull public static < T > UnicastSubject < T > create ( int capacityHint , Runnable onTerminate ) { } }

implementation: return new UnicastSubject < T > ( capacityHint , onTerminate , true ) ;


signature:
public class UnicastSubject { /** * Creates an UnicastSubject with an internal buffer capacity hint 16 and given delay error flag .
 * < p > The callback , if not null , is called exactly once and
 * non - overlapped with any active replay .
 * < p > History : 2.0.8 - experimental
 * @ param < T > the value type
 * @ param delayError deliver pending onNext events before onError
 * @ return an UnicastSubject instance
 * @ since 2.2 */
@ CheckReturnValue @ NonNull public static < T > UnicastSubject < T > create ( boolean delayError ) { } }

implementation: return new UnicastSubject < T > ( bufferSize ( ) , delayError ) ;


signature:
public class PublishProcessor { /** * Tries to emit the item to all currently subscribed Subscribers if all of them
 * has requested some value , returns false otherwise .
 * This method should be called in a sequential manner just like the onXXX methods
 * of the PublishProcessor .
 * Calling with null will terminate the PublishProcessor and a NullPointerException
 * is signalled to the Subscribers .
 * < p > History : 2.0.8 - experimental
 * @ param t the item to emit , not null
 * @ return true if the item was emitted to all Subscribers
 * @ since 2.2 */
public boolean offer ( T t ) { } }

implementation: if ( t == null ) { onError ( new NullPointerException ( "onNext called with null. Null values are generally not allowed in 2.x operators and sources." ) ) ; return true ; } PublishSubscription < T > [ ] array = subscribers . get ( ) ; for ( PublishSubscription < T > s : array ) { if ( s . isFull ( ) ) { return false ; } } for ( PublishSubscription < T > s : array ) { s . onNext ( t ) ; } return true ;


signature:
public class BasicFuseableObserver { /** * final : fixed protocol steps to support fuseable and non - fuseable upstream */
@ SuppressWarnings ( "unchecked" ) @ Override public final void onSubscribe ( Disposable d ) { } }

implementation: if ( DisposableHelper . validate ( this . upstream , d ) ) { this . upstream = d ; if ( d instanceof QueueDisposable ) { this . qd = ( QueueDisposable < T > ) d ; } if ( beforeDownstream ( ) ) { downstream . onSubscribe ( this ) ; afterDownstream ( ) ; } }


signature: public class BasicFuseableObserver { @ Override public void onError ( Throwable t ) { } }

implementation: if ( done ) { RxJavaPlugins . onError ( t ) ; return ; } done = true ; downstream . onError ( t ) ;


signature:
public class BasicFuseableObserver { /** * Rethrows the throwable if it is a fatal exception or calls { @ link # onError ( Throwable ) } .
 * @ param t the throwable to rethrow or signal to the actual subscriber */
protected final void fail ( Throwable t ) { } }

implementation: Exceptions . throwIfFatal ( t ) ; upstream . dispose ( ) ; onError ( t ) ;


signature:
public class BasicFuseableObserver { /** * Calls the upstream ' s QueueDisposable . requestFusion with the mode and
 * saves the established mode in { @ link # sourceMode } if that mode doesn ' t
 * have the { @ link QueueDisposable # BOUNDARY } flag set .
 * If the upstream doesn ' t support fusion ( { @ link # qd } is null ) , the method
 * returns { @ link QueueDisposable # NONE } .
 * @ param mode the fusion mode requested
 * @ return the established fusion mode */
protected final int transitiveBoundaryFusion ( int mode ) { } }

implementation: QueueDisposable < T > qd = this . qd ; if ( qd != null ) { if ( ( mode & BOUNDARY ) == 0 ) { int m = qd . requestFusion ( mode ) ; if ( m != NONE ) { sourceMode = m ; } return m ; } } return NONE ;


signature:
public class BlockingMultiObserver { /** * Block until the latch is counted down and return the error received or null if no
 * error happened .
 * @ return the error received or null */
public Throwable blockingGetError ( ) { } }

implementation: if ( getCount ( ) != 0 ) { try { BlockingHelper . verifyNonBlocking ( ) ; await ( ) ; } catch ( InterruptedException ex ) { dispose ( ) ; return ex ; } } return error ;


signature:
public class BlockingMultiObserver { /** * Block until the latch is counted down and return the error received or
 * when the wait is interrupted or times out , null otherwise .
 * @ param timeout the timeout value
 * @ param unit the time unit
 * @ return the error received or null */
public Throwable blockingGetError ( long timeout , TimeUnit unit ) { } }

implementation: if ( getCount ( ) != 0 ) { try { BlockingHelper . verifyNonBlocking ( ) ; if ( ! await ( timeout , unit ) ) { dispose ( ) ; throw ExceptionHelper . wrapOrThrow ( new TimeoutException ( timeoutMessage ( timeout , unit ) ) ) ; } } catch ( InterruptedException ex ) { dispose ( ) ; throw ExceptionHelper . wrapOrThrow ( ex ) ; } } return error ;


signature:
public class BlockingMultiObserver { /** * Block until the observer terminates and return true ; return false if
 * the wait times out .
 * @ param timeout the timeout value
 * @ param unit the time unit
 * @ return true if the observer terminated in time , false otherwise */
public boolean blockingAwait ( long timeout , TimeUnit unit ) { } }

implementation: if ( getCount ( ) != 0 ) { try { BlockingHelper . verifyNonBlocking ( ) ; if ( ! await ( timeout , unit ) ) { dispose ( ) ; return false ; } } catch ( InterruptedException ex ) { dispose ( ) ; throw ExceptionHelper . wrapOrThrow ( ex ) ; } } Throwable ex = error ; if ( ex != null ) { throw ExceptionHelper . wrapOrThrow ( ex ) ; } return true ;


signature:
public class ReplayProcessor { /** * Creates an unbounded ReplayProcessor with the specified initial buffer capacity .
 * Use this method to avoid excessive array reallocation while the internal buffer grows to accommodate new
 * items . For example , if you know that the buffer will hold 32k items , you can ask the
 * { @ code ReplayProcessor } to preallocate its internal array with a capacity to hold that many items . Once
 * the items start to arrive , the internal array won ' t need to grow , creating less garbage and no overhead
 * due to frequent array - copying .
 * @ param < T >
 * the type of items observed and emitted by this type of processor
 * @ param capacityHint
 * the initial buffer capacity
 * @ return the created processor */
@ CheckReturnValue @ NonNull public static < T > ReplayProcessor < T > create ( int capacityHint ) { } }

implementation: return new ReplayProcessor < T > ( new UnboundedReplayBuffer < T > ( capacityHint ) ) ;


signature:
public class ReplayProcessor { /** * Creates a size - bounded ReplayProcessor .
 * In this setting , the { @ code ReplayProcessor } holds at most { @ code size } items in its internal buffer and
 * discards the oldest item .
 * When { @ code Subscriber } s subscribe to a terminated { @ code ReplayProcessor } , they are guaranteed to see at most
 * { @ code size } { @ code onNext } events followed by a termination event .
 * If a { @ code Subscriber } subscribes while the { @ code ReplayProcessor } is active , it will observe all items in the
 * buffer at that point in time and each item observed afterwards , even if the buffer evicts items due to
 * the size constraint in the mean time . In other words , once a { @ code Subscriber } subscribes , it will receive items
 * without gaps in the sequence .
 * @ param < T >
 * the type of items observed and emitted by this type of processor
 * @ param maxSize
 * the maximum number of buffered items
 * @ return the created processor */
@ CheckReturnValue @ NonNull public static < T > ReplayProcessor < T > createWithSize ( int maxSize ) { } }

implementation: return new ReplayProcessor < T > ( new SizeBoundReplayBuffer < T > ( maxSize ) ) ;


signature:
public class ReplayProcessor { /** * / * test */
static < T > ReplayProcessor < T > createUnbounded ( ) { } }

implementation: return new ReplayProcessor < T > ( new SizeBoundReplayBuffer < T > ( Integer . MAX_VALUE ) ) ;


signature:
public class ReplayProcessor { /** * Creates a time - bounded ReplayProcessor .
 * In this setting , the { @ code ReplayProcessor } internally tags each observed item with a timestamp value
 * supplied by the { @ link Scheduler } and keeps only those whose age is less than the supplied time value
 * converted to milliseconds . For example , an item arrives at T = 0 and the max age is set to 5 ; at T & gt ; = 5
 * this first item is then evicted by any subsequent item or termination event , leaving the buffer empty .
 * Once the processor is terminated , { @ code Subscriber } s subscribing to it will receive items that remained in the
 * buffer after the terminal event , regardless of their age .
 * If a { @ code Subscriber } subscribes while the { @ code ReplayProcessor } is active , it will observe only those items
 * from within the buffer that have an age less than the specified time , and each item observed thereafter ,
 * even if the buffer evicts items due to the time constraint in the mean time . In other words , once a
 * { @ code Subscriber } subscribes , it observes items without gaps in the sequence except for any outdated items at the
 * beginning of the sequence .
 * Note that terminal notifications ( { @ code onError } and { @ code onComplete } ) trigger eviction as well . For
 * example , with a max age of 5 , the first item is observed at T = 0 , then an { @ code onComplete } notification
 * arrives at T = 10 . If a { @ code Subscriber } subscribes at T = 11 , it will find an empty { @ code ReplayProcessor } with just
 * an { @ code onComplete } notification .
 * @ param < T >
 * the type of items observed and emitted by this type of processor
 * @ param maxAge
 * the maximum age of the contained items
 * @ param unit
 * the time unit of { @ code time }
 * @ param scheduler
 * the { @ link Scheduler } that provides the current time
 * @ return the created processor */
@ CheckReturnValue @ NonNull public static < T > ReplayProcessor < T > createWithTime ( long maxAge , TimeUnit unit , Scheduler scheduler ) { } }

implementation: return new ReplayProcessor < T > ( new SizeAndTimeBoundReplayBuffer < T > ( Integer . MAX_VALUE , maxAge , unit , scheduler ) ) ;


signature:
public class BasicFuseableSubscriber { /** * final : fixed protocol steps to support fuseable and non - fuseable upstream */
@ SuppressWarnings ( "unchecked" ) @ Override public final void onSubscribe ( Subscription s ) { } }

implementation: if ( SubscriptionHelper . validate ( this . upstream , s ) ) { this . upstream = s ; if ( s instanceof QueueSubscription ) { this . qs = ( QueueSubscription < T > ) s ; } if ( beforeDownstream ( ) ) { downstream . onSubscribe ( this ) ; afterDownstream ( ) ; } }


signature:
public class BasicFuseableSubscriber { /** * Rethrows the throwable if it is a fatal exception or calls { @ link # onError ( Throwable ) } .
 * @ param t the throwable to rethrow or signal to the actual subscriber */
protected final void fail ( Throwable t ) { } }

implementation: Exceptions . throwIfFatal ( t ) ; upstream . cancel ( ) ; onError ( t ) ;


signature:
public class BasicFuseableSubscriber { /** * Calls the upstream ' s QueueSubscription . requestFusion with the mode and
 * saves the established mode in { @ link # sourceMode } if that mode doesn ' t
 * have the { @ link QueueSubscription # BOUNDARY } flag set .
 * If the upstream doesn ' t support fusion ( { @ link # qs } is null ) , the method
 * returns { @ link QueueSubscription # NONE } .
 * @ param mode the fusion mode requested
 * @ return the established fusion mode */
protected final int transitiveBoundaryFusion ( int mode ) { } }

implementation: QueueSubscription < T > qs = this . qs ; if ( qs != null ) { if ( ( mode & BOUNDARY ) == 0 ) { int m = qs . requestFusion ( mode ) ; if ( m != NONE ) { sourceMode = m ; } return m ; } } return NONE ;