hu.akarnokd.rxjava2.basetypes

## Class Perhaps<T>

- java.lang.Object
- - hu.akarnokd.rxjava2.basetypes.Perhaps<T>

Type Parameters:
  `T` - the value type

All Implemented Interfaces:
  org.reactivestreams.Publisher<T>

Direct Known Subclasses:
  PerhapsProcessor

    public abstract class Perhaps<T>
    extends java.lang.Object
    implements org.reactivestreams.Publisher<T>

A 0-1-error base reactive type, similar to Maybe, implementing the Reactive-Streams Publisher interface.

Since:
  0.14.0

### Constructor Summary

Constructors
Constructor and Description
`Perhaps()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static <T> Perhaps<T>` `amb(java.lang.Iterable<? extends Perhaps<? extends T>> sources)` Emit the events of the Perhaps that reacts first.
`static <T> Perhaps<T>` `ambArray(Perhaps<? extends T>... sources)` Emit the events of the Perhaps that reacts first.
`Perhaps<T>` `ambWith(Perhaps<? extends T> other)` Signals the events of this or the other Perhaps whichever signals first.
`Perhaps<T>` `andThen(Nono other)` Runs this Perhaps and then runs the other Nono source, only emitting this Perhaps' success value if the other Nono source completes normally.
`io.reactivex.Flowable<T>` `andThen(org.reactivestreams.Publisher<? extends T> other)` Runs this Perhaps and emits its value followed by running the other Publisher and emitting its values.
`T` `blockingGet()` Blockingly awaits indefinitely the success value of this Perhaps or rethrows its error (wrapped into a RuntimeException if necessary).
`T` `blockingGet(long timeout, java.util.concurrent.TimeUnit unit)` Blockingly awaits at most the given timeout for the success value of this Perhaps or rethrows its error (wrapped into a RuntimeException if necessary).
`void` `blockingSubscribe()` Blocks until this Perhaps terminates and ignores the signals it produced.
`void` `blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext)` Blocks until this Perhaps terminates and calls the onNext with the success value.
`void` `blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext, io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)` Blocks until this Perhaps terminates and calls the onNext with the success value or calls the onError with the error Throwable.
`void` `blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext, io.reactivex.functions.Consumer<? super java.lang.Throwable> onError, io.reactivex.functions.Action onComplete)` Blocks until this Perhaps produces its terminal signal and calls the appropriate callback(s) based on the signal type.
`Perhaps<T>` `cache()` Caches the value or error event of the upstream Perhaps and relays/replays it to Subscribers.
`<R> Perhaps<R>` `compose(io.reactivex.functions.Function<? super Perhaps<T>,? extends Perhaps<R>> composer)` Applies a function to this Perhaps and returns the Perhaps it returned.
`static <T> io.reactivex.Flowable<T>` `concat(java.lang.Iterable<? extends Perhaps<? extends T>> sources)` Concatenate the values in order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `concat(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)` Concatenate the values in order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `concat(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources, int prefetch)` Concatenate the values in order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `concatArray(Perhaps<? extends T>... sources)` Concatenate the values in order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `concatArrayDelayError(Perhaps<? extends T>... sources)` Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `concatDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources)` Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)` Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources, int prefetch)` Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources, int prefetch, boolean tillTheEnd)` Concatenate the values in order from a sequence of Perhaps sources, delaying errors till a source terminates or the whole sequence terminates.
`io.reactivex.Flowable<T>` `concatWith(org.reactivestreams.Publisher<? extends T> other)` Runs this Perhaps and emits its value followed by running the other Publisher and emitting its values.
`static <T> Perhaps<T>` `create(io.reactivex.MaybeOnSubscribe<T> onCreate)` Create a Perhaps that for each incoming Subscriber calls a callback to emit a sync or async events in a thread-safe, backpressure-aware and cancellation-safe manner.
`Perhaps<T>` `defaultIfEmpty(T item)` Signal the given item if this Perhaps is empty.
`static <T> Perhaps<T>` `defer(java.util.concurrent.Callable<? extends Perhaps<? extends T>> supplier)` Defers the creation of the actual Perhaps instance until subscription time and for each downstream Subscriber the given callable is called.
`Perhaps<T>` `delay(long delay, java.util.concurrent.TimeUnit unit)` Delay the emission of the signals of this Perhaps by the given amount of time.
`Perhaps<T>` `delay(long delay, java.util.concurrent.TimeUnit unit, io.reactivex.Scheduler scheduler)` Delay the emission of the signals of this Perhaps by the given amount of time.
`Perhaps<T>` `delay(org.reactivestreams.Publisher<?> other)` Delay the emission of the signals of this Perhaps till the other Publisher signals an item or completes.
`Perhaps<T>` `delaySubscription(long delay, java.util.concurrent.TimeUnit unit)` Delay the subscription to this Perhaps by the given time amount.
`Perhaps<T>` `delaySubscription(long delay, java.util.concurrent.TimeUnit unit, io.reactivex.Scheduler scheduler)` Delay the subscription to this Perhaps by the given time amount, running on the specified Scheduler.
`Perhaps<T>` `delaySubscription(org.reactivestreams.Publisher<?> other)` Delay the subscription to this Perhaps until the other Publisher signals an item or completes.
`Perhaps<T>` `doAfterNext(io.reactivex.functions.Consumer<? super T> onAfterNext)` Executes a callback after the value is emitted to downstream.
`Perhaps<T>` `doAfterTerminate(io.reactivex.functions.Action onAfterTerminate)` Executes the callback after this Perhaps terminates and the downstream is notified.
`Perhaps<T>` `doFinally(io.reactivex.functions.Action onFinally)` Executes the callback exactly if the upstream terminates or the downstream cancels the sequence.
`Perhaps<T>` `doOnCancel(io.reactivex.functions.Action onCancel)` Executes the callback if the downstream cancels the sequence.
`Perhaps<T>` `doOnComplete(io.reactivex.functions.Action onComplete)` Executes a callback when the upstream completes normally.
`Perhaps<T>` `doOnError(io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)` Executes a callback when the upstream signals an error.
`Perhaps<T>` `doOnNext(io.reactivex.functions.Consumer<? super T> onNext)` Executes a callback before the value is emitted to downstream.
`Perhaps<T>` `doOnRequest(io.reactivex.functions.LongConsumer onRequest)` Executes the callback when the downstream requests from this Perhaps.
`Perhaps<T>` `doOnSubscribe(io.reactivex.functions.Consumer<? super org.reactivestreams.Subscription> onSubscribe)` Executes a callback when the upstream calls onSubscribe.
`static <T> Perhaps<T>` `empty()` Returns an empty Perhaps.
`static <T> Perhaps<T>` `error(java.util.concurrent.Callable<? extends java.lang.Throwable> errorSupplier)` Returns a Perhaps that signals the error returned from the errorSupplier to each individual Subscriber.
`static <T> Perhaps<T>` `error(java.lang.Throwable error)` Returns a Perhaps that signals the given error to Subscribers.
`Perhaps<T>` `filter(io.reactivex.functions.Predicate<? super T> predicate)` Filters the value from upstream with a predicate and completes if the filter didn't match it.
`<R> Perhaps<R>` `flatMap(io.reactivex.functions.Function<? super T,? extends Perhaps<? extends R>> mapper)` Maps the upstream's value into another Perhaps and emits its resulting events.
`<R> Perhaps<R>` `flatMap(io.reactivex.functions.Function<? super T,? extends Perhaps<? extends R>> onSuccessMapper, io.reactivex.functions.Function<? super java.lang.Throwable,? extends Perhaps<? extends R>> onErrorMapper, java.util.concurrent.Callable<? extends Perhaps<? extends R>> onCompleteMapper)` Maps the upstream events into other Perhaps instances and emits its resulting events.
`<R> io.reactivex.Flowable<R>` `flatMapPublisher(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)` Maps the upstream value into a Publisher and emits all of its events.
`static <T> Perhaps<T>` `fromAction(io.reactivex.functions.Action action)` Run an action for each individual Subscriber and terminate.
`static <T> Perhaps<T>` `fromCallable(java.util.concurrent.Callable<T> callable)` Runs a Callable and emits its resulting value or its exception; null is considered to be an indication for an empty Perhaps.
`static <T> Perhaps<T>` `fromCompletable(io.reactivex.CompletableSource source)` Wraps a Completable and signals its terminal events.
`static <T> Perhaps<T>` `fromFuture(java.util.concurrent.Future<? extends T> future)` When subscribed, the future is awaited blockingly and indefinitely for its result value; null result will yield a NoSuchElementException.
`static <T> Perhaps<T>` `fromFuture(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit)` When subscribed, the future is awaited blockingly for a given amount of time for its result value; null result will yield a NoSuchElementException and a timeout will yield a TimeoutException.
`static <T> Perhaps<T>` `fromMaybe(io.reactivex.MaybeSource<T> source)` Wraps a Maybe and signals its events.
`static <T> Perhaps<T>` `fromPublisher(org.reactivestreams.Publisher<T> source)` Wraps a Publisher and signals its single value or completion signal or signals IndexOutOfBoundsException if the Publisher has more than one element.
`static <T> Perhaps<T>` `fromSingle(io.reactivex.SingleSource<T> source)` Wraps a Single and signals its events.
`static <T> io.reactivex.functions.Function<Perhaps<T>,Perhaps<T>>` `getOnAssemblyHandler()` Returns the current onAssembly handler.
`Perhaps<T>` `hide()` Hides the identity of this Perhaps instance, including its subscriber.
`Nono` `ignoreElement()` Ignore the element of this Perhaps.
`static <T> Perhaps<T>` `just(T item)` Returns a Perhaps that signals the given item.
`<R> Perhaps<R>` `lift(io.reactivex.functions.Function<org.reactivestreams.Subscriber<? super R>,org.reactivestreams.Subscriber<? super T>> onLift)` Map the downstream Subscriber into an upstream Subscriber.
`<R> Perhaps<R>` `map(io.reactivex.functions.Function<? super T,? extends R> mapper)` Maps the value of this Perhaps into another value (of possibly different type).
`Perhaps<T>` `mapError(io.reactivex.functions.Function<? super java.lang.Throwable,? extends java.lang.Throwable> errorMapper)` Maps the error from upstream into another Throwable error.
`static <T> io.reactivex.Flowable<T>` `merge(java.lang.Iterable<? extends Perhaps<? extends T>> sources)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `merge(java.lang.Iterable<? extends Perhaps<? extends T>> sources, int maxConcurrency)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `merge(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `merge(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources, int maxConcurrency)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `mergeArray(int maxConcurrency, Perhaps<? extends T>... sources)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `mergeArray(Perhaps<? extends T>... sources)` Merge the values in arbitrary order from a sequence of Perhaps sources.
`static <T> io.reactivex.Flowable<T>` `mergeArrayDelayError(int maxConcurrency, Perhaps<? extends T>... sources)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `mergeArrayDelayError(Perhaps<? extends T>... sources)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `mergeDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `mergeDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources, int maxConcurrency)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `mergeDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`static <T> io.reactivex.Flowable<T>` `mergeDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources, int maxConcurrency)` Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.
`io.reactivex.Flowable<T>` `mergeWith(org.reactivestreams.Publisher<? extends T> other)` Merges this Perhaps with another Publisher and emits all their values.
`static <T> Perhaps<T>` `never()` Returns a Perhaps that never signals any item or terminal event.
`Perhaps<T>` `observeOn(io.reactivex.Scheduler scheduler)` Observe the events of this Perhaps on the specified scheduler.
`protected static <T> Perhaps<T>` `onAssembly(Perhaps<T> source)`
`Perhaps<T>` `onErrorComplete()` Completes in case the upstream signals an error.
`Perhaps<T>` `onErrorResumeNext(io.reactivex.functions.Function<? super java.lang.Throwable,? extends Perhaps<? extends T>> fallbackSupplier)` If the upstream signals an error, apply the given function to that Throwable error and resume with the returned Perhaps.
`Perhaps<T>` `onErrorResumeWith(Perhaps<? extends T> fallback)` If the upstream signals an error, switch to the given fallback Perhaps.
`Perhaps<T>` `onErrorReturnItem(T item)` If the upstream signals an error, it is replaced by a signal of the given item and normal completion.
`io.reactivex.Flowable<T>` `repeat()` Repeats this Perhaps indefinitely.
`io.reactivex.Flowable<T>` `repeat(io.reactivex.functions.BooleanSupplier stop)` Repeats this Perhaps until the given boolean supplier returns true when an repeat iteration of this Perhaps completes.
`io.reactivex.Flowable<T>` `repeat(long times)` Repeats this Perhaps at most the given number of times.
`io.reactivex.Flowable<T>` `repeatWhen(io.reactivex.functions.Function<? super io.reactivex.Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)` Repeats this Perhaps when the Publisher returned by the handler function emits an item or terminates if this Publisher terminates.
`Perhaps<T>` `retry()` Retry this Perhaps indefinitely if it fails.
`Perhaps<T>` `retry(long times)` Retry this Perhaps at most the given number of times if it fails.
`Perhaps<T>` `retry(io.reactivex.functions.Predicate<? super java.lang.Throwable> predicate)` Retry this Perhaps if the predicate returns true for the latest failure Throwable.
`Perhaps<T>` `retryWhen(io.reactivex.functions.Function<? super io.reactivex.Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)` Retry this Perhaps if the Publisher returned by the handler signals an item in response to the failure Throwable.
`static <T> void` `setOnAssemblyHandler(io.reactivex.functions.Function<Perhaps<T>,Perhaps<T>> handler)` Set the onAssembly handler.
`io.reactivex.disposables.Disposable` `subscribe()` Subscribe to this Perhaps and ignore any signal it produces.
`io.reactivex.disposables.Disposable` `subscribe(io.reactivex.functions.Consumer<? super T> onNext)` Subscribes to this Perhaps and calls the onNext if this Perhaps succeeds.
`io.reactivex.disposables.Disposable` `subscribe(io.reactivex.functions.Consumer<? super T> onNext, io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)` Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.
`io.reactivex.disposables.Disposable` `subscribe(io.reactivex.functions.Consumer<? super T> onNext, io.reactivex.functions.Consumer<? super java.lang.Throwable> onError, io.reactivex.functions.Action onComplete)` Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.
`void` `subscribe(org.reactivestreams.Subscriber<? super T> s)`
`protected abstract void` `subscribeActual(org.reactivestreams.Subscriber<? super T> s)` Implement this method to react to a Subscriber subscribing to this Perhaps.
`Perhaps<T>` `subscribeOn(io.reactivex.Scheduler scheduler)` Subscribes to the upstream Perhaps and requests on the specified Scheduler.
`<E extends org.reactivestreams.Subscriber<? super T>> E` `subscribeWith(E s)` Subscribe with a Subscriber (subclass) and return it as is.
`Perhaps<T>` `switchIfEmpty(Perhaps<? extends T> other)` Switch to the other Perhaps if this Perhaps is empty.
`Perhaps<T>` `takeUntil(org.reactivestreams.Publisher<?> other)` Try consuming this Perhaps until the other Publisher signals an item or completes which then completes the Perhaps.
`io.reactivex.subscribers.TestSubscriber<T>` `test()` Creates a TestSubscriber and subscribes it to this Perhaps.
`io.reactivex.subscribers.TestSubscriber<T>` `test(boolean cancel)` Creates a TestSubscriber, optionally cancels it, and subscribes it to this Perhaps.
`io.reactivex.subscribers.TestSubscriber<T>` `test(long initialRequest)` Creates a TestSubscriber with the given initial request and subscribes it to this Perhaps.
`io.reactivex.subscribers.TestSubscriber<T>` `test(long initialRequest, boolean cancel)` Creates a TestSubscriber with the given initial request, optionally cancels it, and subscribes it to this Perhaps.
`Perhaps<T>` `timeout(long timeout, java.util.concurrent.TimeUnit unit)` Signals a TimeoutException if the Perhaps doesn't signal an item within the specified time.
`Perhaps<T>` `timeout(long timeout, java.util.concurrent.TimeUnit unit, Perhaps<? extends T> fallback)` Switch to the fallback Perhaps if this Perhaps doesn't signal an item (or terminates) within the specified time.
`Perhaps<T>` `timeout(long timeout, java.util.concurrent.TimeUnit unit, io.reactivex.Scheduler scheduler)` Signals a TimeoutException if the Perhaps doesn't signal an item or (terminates) within the specified time.
`Perhaps<T>` `timeout(long timeout, java.util.concurrent.TimeUnit unit, io.reactivex.Scheduler scheduler, Perhaps<? extends T> fallback)` Switch to the fallback Perhaps if this Perhaps doesn't signal an item (or terminates) within the specified time.
`Perhaps<T>` `timeout(org.reactivestreams.Publisher<?> other)` Signal a TimeoutException if the other Publisher signals an item or completes before this Perhaps does.
`Perhaps<T>` `timeout(org.reactivestreams.Publisher<?> other, Perhaps<? extends T> fallback)` Switch to the fallback Perhaps if the other Publisher signals an item or completes before this Perhaps does.
`static Perhaps<java.lang.Long>` `timer(long delay, java.util.concurrent.TimeUnit unit)` Signals a 0L after the specified amount of time has passed since subscription.
`static Perhaps<java.lang.Long>` `timer(long delay, java.util.concurrent.TimeUnit unit, io.reactivex.Scheduler scheduler)` Signals a 0L after the specified amount of time has passed since subscription on the specified scheduler.
`<R> R` `to(io.reactivex.functions.Function<? super Perhaps<T>,R> converter)` Applies the function, fluently to this Perhaps and returns the value it returns.
`io.reactivex.Flowable<T>` `toFlowable()` Convert this Perhaps into a Flowable.
`java.util.concurrent.Future<T>` `toFuture()` Converts this Perhaps into a Future and signals its single value or null if this Perhaps is empty.
`io.reactivex.Maybe<T>` `toMaybe()` Convert this Perhaps into a Maybe.
`io.reactivex.Observable<T>` `toObservable()` Convert this Perhaps into an Observable.
`Perhaps<T>` `unsubscribeOn(io.reactivex.Scheduler scheduler)` If the downstream cancels, the upstream is cancelled on the specified scheduler.
`static <T,R> Perhaps<T>` `using(java.util.concurrent.Callable<R> resourceSupplier, io.reactivex.functions.Function<? super R,? extends Perhaps<? extends T>> sourceSupplier, io.reactivex.functions.Consumer<? super R> disposer)` Generate a resource and a Perhaps based on that resource and then dispose that resource eagerly when the Perhaps terminates or the downstream cancels the sequence.

`static <T,R> Perhaps<T>`

`using(java.util.concurrent.Callable<R> resourceSupplier, io.reactivex.functions.Function<? super R,? extends Perhaps<? extends T>> sourceSupplier, io.reactivex.functions.Consumer<? super R> disposer, boolean eager)`
Generate a resource and a Perhaps based on that resource and then dispose that resource eagerly when the Perhaps terminates or the downstream cancels the sequence.

`static <T,R> Perhaps<R>` `zip(java.lang.Iterable<? extends Perhaps<? extends T>> sources, io.reactivex.functions.Function<? super java.lang.Object[],? extends R> zipper)` Combines the Perhaps values of all the sources via a zipper function into a single resulting value.
`static <T,R> Perhaps<R>` `zipArray(io.reactivex.functions.Function<? super java.lang.Object[],? extends R> zipper, Perhaps<? extends T>... sources)` Combines the Perhaps values of all the sources via a zipper function into a single resulting value.
`<U,R> Perhaps<R>` `zipWith(Perhaps<? extends U> other, io.reactivex.functions.BiFunction<? super T,? super U,? extends R> zipper)` Zips the value of this Perhaps with the other Perhaps through a BiFunction.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Perhaps

    public Perhaps()

### Method Detail

#### getOnAssemblyHandler

    public static <T> io.reactivex.functions.Function<Perhaps<T>,Perhaps<T>> getOnAssemblyHandler()

Returns the current onAssembly handler.

Type Parameters:
  `T` - the target value type
Returns:
  the current handler, maybe null

#### setOnAssemblyHandler

    public static <T> void setOnAssemblyHandler(io.reactivex.functions.Function<Perhaps<T>,Perhaps<T>> handler)

Set the onAssembly handler.

Type Parameters:
  `T` - the target value type
Parameters:
  `handler` - the handler, null clears the handler

#### onAssembly

    protected static <T> Perhaps<T> onAssembly(Perhaps<T> source)

#### create

    public static <T> Perhaps<T> create(io.reactivex.MaybeOnSubscribe<T> onCreate)

Create a Perhaps that for each incoming Subscriber calls a callback to emit a sync or async events in a thread-safe, backpressure-aware and cancellation-safe manner.

Type Parameters:
  `T` - the value type emitted
Parameters:
  `onCreate` - the callback called for each individual subscriber with an abstraction of the incoming Subscriber.
Returns:
  th new Perhaps instance

#### just

    public static <T> Perhaps<T> just(T item)

Returns a Perhaps that signals the given item.

Type Parameters:
  `T` - the value type
Parameters:
  `item` - the item to signal, not null
Returns:
  the new Perhaps instance

#### empty

    public static <T> Perhaps<T> empty()

Returns an empty Perhaps.

Type Parameters:
  `T` - the value type
Returns:
  the shared Perhaps instance

#### error

    public static <T> Perhaps<T> error(java.lang.Throwable error)

Returns a Perhaps that signals the given error to Subscribers.

Type Parameters:
  `T` - the value type
Parameters:
  `error` - the error to signal, not null
Returns:
  the new Perhaps instance

#### error

    public static <T> Perhaps<T> error(java.util.concurrent.Callable<? extends java.lang.Throwable> errorSupplier)

Returns a Perhaps that signals the error returned from the errorSupplier to each individual Subscriber.

Type Parameters:
  `T` - the value type
Parameters:
  `errorSupplier` - the supplier called for each Subscriber to return a Throwable to be signalled
Returns:
  the new Perhaps instance

#### never

    public static <T> Perhaps<T> never()

Returns a Perhaps that never signals any item or terminal event.

Type Parameters:
  `T` - the value type
Returns:
  the shared Perhaps instance

#### fromCallable

    public static <T> Perhaps<T> fromCallable(java.util.concurrent.Callable<T> callable)

Runs a Callable and emits its resulting value or its exception; null is considered to be an indication for an empty Perhaps.

Type Parameters:
  `T` - the value type
Parameters:
  `callable` - the callable to call for each individual Subscriber
Returns:
  the new Perhaps instance

#### fromAction

    public static <T> Perhaps<T> fromAction(io.reactivex.functions.Action action)

Run an action for each individual Subscriber and terminate.

Type Parameters:
  `T` - the value type
Parameters:
  `action` - the action to call for each individual Subscriber
Returns:
  the new Perhaps instance

#### fromFuture

    public static <T> Perhaps<T> fromFuture(java.util.concurrent.Future<? extends T> future)

When subscribed, the future is awaited blockingly and indefinitely for its result value; null result will yield a NoSuchElementException.

Type Parameters:
  `T` - the value type
Parameters:
  `future` - the future to await
Returns:
  the new Perhaps instance

#### fromFuture

    public static <T> Perhaps<T> fromFuture(java.util.concurrent.Future<? extends T> future,
                                            long timeout,
                                            java.util.concurrent.TimeUnit unit)

When subscribed, the future is awaited blockingly for a given amount of time for its result value; null result will yield a NoSuchElementException and a timeout will yield a TimeoutException.

Type Parameters:
  `T` - the value type
Parameters:
  `future` - the future to await
  `timeout` - the timeout value
  `unit` - the time unit
Returns:
  the new Perhaps instance

#### fromPublisher

    public static <T> Perhaps<T> fromPublisher(org.reactivestreams.Publisher<T> source)

Wraps a Publisher and signals its single value or completion signal or signals IndexOutOfBoundsException if the Publisher has more than one element.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source Publisher
Returns:
  the new Perhaps instance

#### fromSingle

    public static <T> Perhaps<T> fromSingle(io.reactivex.SingleSource<T> source)

Wraps a Single and signals its events.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source
Returns:
  the new Perhaps instance

#### fromMaybe

    public static <T> Perhaps<T> fromMaybe(io.reactivex.MaybeSource<T> source)

Wraps a Maybe and signals its events.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source
Returns:
  the new Perhaps instance

#### fromCompletable

    public static <T> Perhaps<T> fromCompletable(io.reactivex.CompletableSource source)

Wraps a Completable and signals its terminal events.

Type Parameters:
  `T` - the value type
Parameters:
  `source` - the source
Returns:
  the new Perhaps instance

#### defer

    public static <T> Perhaps<T> defer(java.util.concurrent.Callable<? extends Perhaps<? extends T>> supplier)

Defers the creation of the actual Perhaps instance until subscription time and for each downstream Subscriber the given callable is called.

Type Parameters:
  `T` - the value type
Parameters:
  `supplier` - the Callable called for each individual Subscriber to return a Perhaps to be subscribe to.
Returns:
  the new Perhaps instance

#### amb

    public static <T> Perhaps<T> amb(java.lang.Iterable<? extends Perhaps<? extends T>> sources)

Emit the events of the Perhaps that reacts first.

Type Parameters:
  `T` - the common value type
Parameters:
  `sources` - the Iterable sequence of Perhaps sources
Returns:
  the new Perhaps instance

#### ambArray

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

Emit the events of the Perhaps that reacts first.

Type Parameters:
  `T` - the common value type
Parameters:
  `sources` - the array of Perhaps sources
Returns:
  the new Perhaps instance

#### concat

    public static <T> io.reactivex.Flowable<T> concat(java.lang.Iterable<? extends Perhaps<? extends T>> sources)

Concatenate the values in order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### concat

    public static <T> io.reactivex.Flowable<T> concat(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)

Concatenate the values in order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### concat

    public static <T> io.reactivex.Flowable<T> concat(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources,
                                                      int prefetch)

Concatenate the values in order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `prefetch` - the number of sources to prefetch from upstream
Returns:
  the new Flowable instance

#### concatArray

    public static <T> io.reactivex.Flowable<T> concatArray(Perhaps<? extends T>... sources)

Concatenate the values in order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### concatDelayError

    public static <T> io.reactivex.Flowable<T> concatDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources)

Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### concatDelayError

    public static <T> io.reactivex.Flowable<T> concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)

Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### concatDelayError

    public static <T> io.reactivex.Flowable<T> concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources,
                                                                int prefetch)

Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `prefetch` - the number of sources to prefetch from upstream
Returns:
  the new Flowable instance

#### concatDelayError

    public static <T> io.reactivex.Flowable<T> concatDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources,
                                                                int prefetch,
                                                                boolean tillTheEnd)

Concatenate the values in order from a sequence of Perhaps sources, delaying errors till a source terminates or the whole sequence terminates.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `prefetch` - the number of sources to prefetch from upstream
  `tillTheEnd` - if true, errors are delayed to the very end; if false, an error will be signalled at the end of one source
Returns:
  the new Flowable instance

#### concatArrayDelayError

    public static <T> io.reactivex.Flowable<T> concatArrayDelayError(Perhaps<? extends T>... sources)

Concatenate the values in order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### merge

    public static <T> io.reactivex.Flowable<T> merge(java.lang.Iterable<? extends Perhaps<? extends T>> sources)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### merge

    public static <T> io.reactivex.Flowable<T> merge(java.lang.Iterable<? extends Perhaps<? extends T>> sources,
                                                     int maxConcurrency)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### merge

    public static <T> io.reactivex.Flowable<T> merge(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### merge

    public static <T> io.reactivex.Flowable<T> merge(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources,
                                                     int maxConcurrency)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### mergeArray

    public static <T> io.reactivex.Flowable<T> mergeArray(Perhaps<? extends T>... sources)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### mergeArray

    public static <T> io.reactivex.Flowable<T> mergeArray(int maxConcurrency,
                                                          Perhaps<? extends T>... sources)

Merge the values in arbitrary order from a sequence of Perhaps sources.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### mergeDelayError

    public static <T> io.reactivex.Flowable<T> mergeDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### mergeDelayError

    public static <T> io.reactivex.Flowable<T> mergeDelayError(java.lang.Iterable<? extends Perhaps<? extends T>> sources,
                                                               int maxConcurrency)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### mergeDelayError

    public static <T> io.reactivex.Flowable<T> mergeDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### mergeDelayError

    public static <T> io.reactivex.Flowable<T> mergeDelayError(org.reactivestreams.Publisher<? extends Perhaps<? extends T>> sources,
                                                               int maxConcurrency)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### mergeArrayDelayError

    public static <T> io.reactivex.Flowable<T> mergeArrayDelayError(Perhaps<? extends T>... sources)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
Returns:
  the new Flowable instance

#### mergeArrayDelayError

    public static <T> io.reactivex.Flowable<T> mergeArrayDelayError(int maxConcurrency,
                                                                    Perhaps<? extends T>... sources)

Merge the values in arbitrary order from a sequence of Perhaps sources, delaying errors till all sources terminate.

Type Parameters:
  `T` - the common base value type
Parameters:
  `sources` - the sequence of sources
  `maxConcurrency` - the maximum number of active subscriptions
Returns:
  the new Flowable instance

#### timer

    public static Perhaps<java.lang.Long> timer(long delay,
                                                java.util.concurrent.TimeUnit unit)

Signals a 0L after the specified amount of time has passed since subscription.

Parameters:
  `delay` - the delay time
  `unit` - the time unit
Returns:
  the new Perhaps instance

#### timer

    public static Perhaps<java.lang.Long> timer(long delay,
                                                java.util.concurrent.TimeUnit unit,
                                                io.reactivex.Scheduler scheduler)

Signals a 0L after the specified amount of time has passed since subscription on the specified scheduler.

Parameters:
  `delay` - the delay time
  `unit` - the time unit
  `scheduler` - the scheduler to wait on
Returns:
  the new Perhaps instance

#### using

    public static <T,R> Perhaps<T> using(java.util.concurrent.Callable<R> resourceSupplier,
                                         io.reactivex.functions.Function<? super R,? extends Perhaps<? extends T>> sourceSupplier,
                                         io.reactivex.functions.Consumer<? super R> disposer)

Generate a resource and a Perhaps based on that resource and then dispose that resource eagerly when the Perhaps terminates or the downstream cancels the sequence.

Type Parameters:
  `T` - the value type
  `R` - the resource type
Parameters:
  `resourceSupplier` - the callback to get a resource for each subscriber
  `sourceSupplier` - the function that returns a Perhaps for the generated resource
  `disposer` - the consumer of the resource once the upstream terminates or the downstream cancels
Returns:
  the new Perhaps instance

#### using

    public static <T,R> Perhaps<T> using(java.util.concurrent.Callable<R> resourceSupplier,
                                         io.reactivex.functions.Function<? super R,? extends Perhaps<? extends T>> sourceSupplier,
                                         io.reactivex.functions.Consumer<? super R> disposer,
                                         boolean eager)

Generate a resource and a Perhaps based on that resource and then dispose that resource eagerly when the Perhaps terminates or the downstream cancels the sequence.

Type Parameters:
  `T` - the value type
  `R` - the resource type
Parameters:
  `resourceSupplier` - the callback to get a resource for each subscriber
  `sourceSupplier` - the function that returns a Perhaps for the generated resource
  `disposer` - the consumer of the resource once the upstream terminates or the downstream cancels
  `eager` - if true, the resource is disposed before the terminal event is emitted if false, the resource is disposed after the terminal event has been emitted
Returns:
  the new Perhaps instance

#### zip

    public static <T,R> Perhaps<R> zip(java.lang.Iterable<? extends Perhaps<? extends T>> sources,
                                       io.reactivex.functions.Function<? super java.lang.Object[],? extends R> zipper)

Combines the Perhaps values of all the sources via a zipper function into a single resulting value.

Type Parameters:
  `T` - the common input base type
  `R` - the result type
Parameters:
  `sources` - the sequence of Perhaps sources
  `zipper` - the function takin in an array of values and returns a Perhaps value
Returns:
  the new Perhaps instance

#### zipArray

    public static <T,R> Perhaps<R> zipArray(io.reactivex.functions.Function<? super java.lang.Object[],? extends R> zipper,
                                            Perhaps<? extends T>... sources)

Combines the Perhaps values of all the sources via a zipper function into a single resulting value.

Type Parameters:
  `T` - the common input base type
  `R` - the result type
Parameters:
  `sources` - the sequence of Perhaps sources
  `zipper` - the function takin in an array of values and returns a Perhaps value
Returns:
  the new Perhaps instance

#### ambWith

    public final Perhaps<T> ambWith(Perhaps<? extends T> other)

Signals the events of this or the other Perhaps whichever signals first.

Parameters:
  `other` - the other Perhaps instance
Returns:
  the new Perhaps instance

#### andThen

    public final Perhaps<T> andThen(Nono other)

Runs this Perhaps and then runs the other Nono source, only emitting this Perhaps' success value if the other Nono source completes normally.

Parameters:
  `other` - the other Nono source to run after this
Returns:
  the new Perhaps instance

#### andThen

    public final io.reactivex.Flowable<T> andThen(org.reactivestreams.Publisher<? extends T> other)

Runs this Perhaps and emits its value followed by running the other Publisher and emitting its values.

Parameters:
  `other` - the other Publisher to run after this
Returns:
  the new Flowable instance

#### concatWith

    public final io.reactivex.Flowable<T> concatWith(org.reactivestreams.Publisher<? extends T> other)

Runs this Perhaps and emits its value followed by running the other Publisher and emitting its values.

Parameters:
  `other` - the other Publisher to run after this
Returns:
  the new Flowable instance

#### mergeWith

    public final io.reactivex.Flowable<T> mergeWith(org.reactivestreams.Publisher<? extends T> other)

Merges this Perhaps with another Publisher and emits all their values.

Parameters:
  `other` - the other Publisher source instance
Returns:
  the new Flowable instance

#### zipWith

    public final <U,R> Perhaps<R> zipWith(Perhaps<? extends U> other,
                                          io.reactivex.functions.BiFunction<? super T,? super U,? extends R> zipper)

Zips the value of this Perhaps with the other Perhaps through a BiFunction.

Type Parameters:
  `U` - the value type of the other source
  `R` - the result type
Parameters:
  `other` - the other Perhaps source
  `zipper` - the function receiving each source value and should return a value to be emitted
Returns:
  the new Perhaps instance

#### map

    public final <R> Perhaps<R> map(io.reactivex.functions.Function<? super T,? extends R> mapper)

Maps the value of this Perhaps into another value (of possibly different type).

Type Parameters:
  `R` - the result value type
Parameters:
  `mapper` - the function that receives the onNext value from this Perhaps and returns another value
Returns:
  the new Perhaps instance

#### mapError

    public final Perhaps<T> mapError(io.reactivex.functions.Function<? super java.lang.Throwable,? extends java.lang.Throwable> errorMapper)

Maps the error from upstream into another Throwable error.

Parameters:
  `errorMapper` - the function that receives the upstream error and returns a Throwable
Returns:
  the new Perhaps instance

#### filter

    public final Perhaps<T> filter(io.reactivex.functions.Predicate<? super T> predicate)

Filters the value from upstream with a predicate and completes if the filter didn't match it.

Parameters:
  `predicate` - the predicate receiving the upstream value and returns true if it should be passed along.
Returns:
  the new Perhaps instance

#### ignoreElement

    public final Nono ignoreElement()

Ignore the element of this Perhaps.

Returns:
  the new Nono instance.

#### hide

    public final Perhaps<T> hide()

Hides the identity of this Perhaps instance, including its subscriber.

This allows preventing cerain optimizations as well for diagnostic purposes.

Returns:
  the new Perhaps instance

#### flatMap

    public final <R> Perhaps<R> flatMap(io.reactivex.functions.Function<? super T,? extends Perhaps<? extends R>> mapper)

Maps the upstream's value into another Perhaps and emits its resulting events.

Type Parameters:
  `R` - the output value type
Parameters:
  `mapper` - the function that receives the upstream's value and returns a Perhaps to be consumed.
Returns:
  the new Perhaps instance

#### flatMap

    public final <R> Perhaps<R> flatMap(io.reactivex.functions.Function<? super T,? extends Perhaps<? extends R>> onSuccessMapper,
                                        io.reactivex.functions.Function<? super java.lang.Throwable,? extends Perhaps<? extends R>> onErrorMapper,
                                        java.util.concurrent.Callable<? extends Perhaps<? extends R>> onCompleteMapper)

Maps the upstream events into other Perhaps instances and emits its resulting events.

Note that only one of the onXXXMapper is called based on what the upstream signals, i.e., the usual onNext + onComplete will pick the Perhaps of the onSuccessMapper only and never the onCompleteMapper.

Type Parameters:
  `R` - the result value type
Parameters:
  `onSuccessMapper` - the function called for the upstream value
  `onErrorMapper` - the function called for the upstream error
  `onCompleteMapper` - the function called when the upstream is empty
Returns:
  the new Perhaps instance

#### flatMapPublisher

    public final <R> io.reactivex.Flowable<R> flatMapPublisher(io.reactivex.functions.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)

Maps the upstream value into a Publisher and emits all of its events.

Type Parameters:
  `R` - the result value type
Parameters:
  `mapper` - the function that maps the success value into a Publisher that gets subscribed to and streamed further
Returns:
  the new Flowable type

#### onErrorComplete

    public final Perhaps<T> onErrorComplete()

Completes in case the upstream signals an error.

Returns:
  the new Perhaps instance

#### onErrorReturnItem

    public final Perhaps<T> onErrorReturnItem(T item)

If the upstream signals an error, it is replaced by a signal of the given item and normal completion.

Parameters:
  `item` - the item to signal in case of an error
Returns:
  the new Perhaps instance

#### onErrorResumeWith

    public final Perhaps<T> onErrorResumeWith(Perhaps<? extends T> fallback)

If the upstream signals an error, switch to the given fallback Perhaps.

Parameters:
  `fallback` - the fallback to switch to in case of an error
Returns:
  the new Perhaps instance

#### onErrorResumeNext

    public final Perhaps<T> onErrorResumeNext(io.reactivex.functions.Function<? super java.lang.Throwable,? extends Perhaps<? extends T>> fallbackSupplier)

If the upstream signals an error, apply the given function to that Throwable error and resume with the returned Perhaps.

Parameters:
  `fallbackSupplier` - the function that receives the upstream Throwable and should return the fallback Perhaps that will be subscribed to as a resumptions
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(long timeout,
                                    java.util.concurrent.TimeUnit unit)

Signals a TimeoutException if the Perhaps doesn't signal an item within the specified time.

Parameters:
  `timeout` - the time to wait for an item
  `unit` - the unit of time
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(long timeout,
                                    java.util.concurrent.TimeUnit unit,
                                    io.reactivex.Scheduler scheduler)

Signals a TimeoutException if the Perhaps doesn't signal an item or (terminates) within the specified time.

Parameters:
  `timeout` - the time to wait for an item
  `unit` - the unit of time
  `scheduler` - the scheduler to wait on
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(long timeout,
                                    java.util.concurrent.TimeUnit unit,
                                    Perhaps<? extends T> fallback)

Switch to the fallback Perhaps if this Perhaps doesn't signal an item (or terminates) within the specified time.

Parameters:
  `timeout` - the time to wait for an item
  `unit` - the unit of time
  `fallback` - the Perhaps to switch to if this Perhaps times out
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(long timeout,
                                    java.util.concurrent.TimeUnit unit,
                                    io.reactivex.Scheduler scheduler,
                                    Perhaps<? extends T> fallback)

Switch to the fallback Perhaps if this Perhaps doesn't signal an item (or terminates) within the specified time.

Parameters:
  `timeout` - the time to wait for an item
  `unit` - the unit of time
  `scheduler` - the scheduler to wait on
  `fallback` - the Perhaps to switch to if this Perhaps times out
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(org.reactivestreams.Publisher<?> other)

Signal a TimeoutException if the other Publisher signals an item or completes before this Perhaps does.

Parameters:
  `other` - the other Publisher that signals the timeout
Returns:
  the new Perhaps instance

#### timeout

    public final Perhaps<T> timeout(org.reactivestreams.Publisher<?> other,
                                    Perhaps<? extends T> fallback)

Switch to the fallback Perhaps if the other Publisher signals an item or completes before this Perhaps does.

Parameters:
  `other` - the other Publisher that signals the timeout
  `fallback` - the Perhaps to switch to in case of a timeout
Returns:
  the new Perhaps instance

#### defaultIfEmpty

    public final Perhaps<T> defaultIfEmpty(T item)

Signal the given item if this Perhaps is empty.

Parameters:
  `item` - the item to signal
Returns:
  the new Perhaps instance

#### switchIfEmpty

    public final Perhaps<T> switchIfEmpty(Perhaps<? extends T> other)

Switch to the other Perhaps if this Perhaps is empty.

Parameters:
  `other` - the other Perhaps to switch to
Returns:
  the new Perhaps instance

#### repeat

    public final io.reactivex.Flowable<T> repeat()

Repeats this Perhaps indefinitely.

Returns:
  the new Flowable instance

#### repeat

    public final io.reactivex.Flowable<T> repeat(long times)

Repeats this Perhaps at most the given number of times.

Parameters:
  `times` - the number of times to repeat
Returns:
  the new Flowable instance

#### repeat

    public final io.reactivex.Flowable<T> repeat(io.reactivex.functions.BooleanSupplier stop)

Repeats this Perhaps until the given boolean supplier returns true when an repeat iteration of this Perhaps completes.

Parameters:
  `stop` - the supplier of a boolean value that should return true to stop repeating.
Returns:
  the new Flowable instance

#### repeatWhen

    public final io.reactivex.Flowable<T> repeatWhen(io.reactivex.functions.Function<? super io.reactivex.Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)

Repeats this Perhaps when the Publisher returned by the handler function emits an item or terminates if this Publisher terminates.

Parameters:
  `handler` - the function that receives Flowable that emits an item when this Perhaps completes and returns a Publisher that should emit an item to trigger a repeat or terminate to trigger a termination.
Returns:
  the new Flowable instance

#### retry

    public final Perhaps<T> retry()

Retry this Perhaps indefinitely if it fails.

Returns:
  the new Perhaps instance

#### retry

    public final Perhaps<T> retry(long times)

Retry this Perhaps at most the given number of times if it fails.

Parameters:
  `times` - the number of times, Long.MAX_VALUE means indefinitely
Returns:
  the new Perhaps instance

#### retry

    public final Perhaps<T> retry(io.reactivex.functions.Predicate<? super java.lang.Throwable> predicate)

Retry this Perhaps if the predicate returns true for the latest failure Throwable.

Parameters:
  `predicate` - the predicate receiving the latest Throwable and if returns true, the Perhaps is retried.
Returns:
  the new Perhaps instance

#### retryWhen

    public final Perhaps<T> retryWhen(io.reactivex.functions.Function<? super io.reactivex.Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)

Retry this Perhaps if the Publisher returned by the handler signals an item in response to the failure Throwable.

Parameters:
  `handler` - the function that receives a Flowable that signals the failure Throwable of this Perhaps and returns a Publisher which triggers a retry or termination.
Returns:
  the new Perhaps instance

#### subscribeOn

    public final Perhaps<T> subscribeOn(io.reactivex.Scheduler scheduler)

Subscribes to the upstream Perhaps and requests on the specified Scheduler.

Parameters:
  `scheduler` - the scheduler to subscribe on
Returns:
  the new Perhaps instance

#### observeOn

    public final Perhaps<T> observeOn(io.reactivex.Scheduler scheduler)

Observe the events of this Perhaps on the specified scheduler.

Parameters:
  `scheduler` - the scheduler to observe events on
Returns:
  the new Perhaps instance

#### unsubscribeOn

    public final Perhaps<T> unsubscribeOn(io.reactivex.Scheduler scheduler)

If the downstream cancels, the upstream is cancelled on the specified scheduler.

Note that normal termination don't trigger cancellation.

Parameters:
  `scheduler` - the scheduler to unsubscribe on
Returns:
  the new Perhaps instance

#### doOnSubscribe

    public final Perhaps<T> doOnSubscribe(io.reactivex.functions.Consumer<? super org.reactivestreams.Subscription> onSubscribe)

Executes a callback when the upstream calls onSubscribe.

Parameters:
  `onSubscribe` - the consumer called with the upstream Subscription
Returns:
  the new Perhaps instance

#### doOnRequest

    public final Perhaps<T> doOnRequest(io.reactivex.functions.LongConsumer onRequest)

Executes the callback when the downstream requests from this Perhaps.

Parameters:
  `onRequest` - the callback called with the request amount
Returns:
  the new Perhaps instance

#### doOnCancel

    public final Perhaps<T> doOnCancel(io.reactivex.functions.Action onCancel)

Executes the callback if the downstream cancels the sequence.

Parameters:
  `onCancel` - the action to call
Returns:
  the new Perhaps instance

#### doOnNext

    public final Perhaps<T> doOnNext(io.reactivex.functions.Consumer<? super T> onNext)

Executes a callback before the value is emitted to downstream.

Parameters:
  `onNext` - the consumer called with the current value before it is is emitted to downstream.
Returns:
  the new Perhaps instance

#### doAfterNext

    public final Perhaps<T> doAfterNext(io.reactivex.functions.Consumer<? super T> onAfterNext)

Executes a callback after the value is emitted to downstream.

Parameters:
  `onAfterNext` - the consumer called with the current value after it is is emitted to downstream.
Returns:
  the new Perhaps instance

#### doOnError

    public final Perhaps<T> doOnError(io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)

Executes a callback when the upstream signals an error.

Parameters:
  `onError` - the consumer called before the error is emitted to the downstream
Returns:
  the new Perhaps instance

#### doOnComplete

    public final Perhaps<T> doOnComplete(io.reactivex.functions.Action onComplete)

Executes a callback when the upstream completes normally.

Parameters:
  `onComplete` - the consumer called before the completion event is emitted to the downstream.
Returns:
  the new Perhaps instance

#### doAfterTerminate

    public final Perhaps<T> doAfterTerminate(io.reactivex.functions.Action onAfterTerminate)

Executes the callback after this Perhaps terminates and the downstream is notified.

Parameters:
  `onAfterTerminate` - the callback to call after the downstream is notified
Returns:
  the new Perhaps instance

#### doFinally

    public final Perhaps<T> doFinally(io.reactivex.functions.Action onFinally)

Executes the callback exactly if the upstream terminates or the downstream cancels the sequence.

Parameters:
  `onFinally` - the action to call
Returns:
  the new Perhaps instance

#### delay

    public final Perhaps<T> delay(long delay,
                                  java.util.concurrent.TimeUnit unit)

Delay the emission of the signals of this Perhaps by the given amount of time.

Parameters:
  `delay` - the delay amount
  `unit` - the time unit of the delay
Returns:
  the new Perhaps instance

#### delay

    public final Perhaps<T> delay(long delay,
                                  java.util.concurrent.TimeUnit unit,
                                  io.reactivex.Scheduler scheduler)

Delay the emission of the signals of this Perhaps by the given amount of time.

Parameters:
  `delay` - the delay amount
  `unit` - the time unit of the delay
  `scheduler` - the scheduler to delay on
Returns:
  the new Perhaps instance

#### delay

    public final Perhaps<T> delay(org.reactivestreams.Publisher<?> other)

Delay the emission of the signals of this Perhaps till the other Publisher signals an item or completes.

Parameters:
  `other` - the other Publisher to delay with
Returns:
  the new Perhaps instance

#### delaySubscription

    public final Perhaps<T> delaySubscription(long delay,
                                              java.util.concurrent.TimeUnit unit)

Delay the subscription to this Perhaps by the given time amount.

Parameters:
  `delay` - the subscription delay amount
  `unit` - the delay time unit
Returns:
  the new Perhaps instance

#### delaySubscription

    public final Perhaps<T> delaySubscription(long delay,
                                              java.util.concurrent.TimeUnit unit,
                                              io.reactivex.Scheduler scheduler)

Delay the subscription to this Perhaps by the given time amount, running on the specified Scheduler.

Parameters:
  `delay` - the subscription delay amount
  `unit` - the delay time unit
  `scheduler` - the scheduler to wait on
Returns:
  the new Perhaps instance

#### delaySubscription

    public final Perhaps<T> delaySubscription(org.reactivestreams.Publisher<?> other)

Delay the subscription to this Perhaps until the other Publisher signals an item or completes.

Parameters:
  `other` - the other Publisher that will trigger the actual subscription to this Perhaps.
Returns:
  the new Perhaps instance

#### lift

    public final <R> Perhaps<R> lift(io.reactivex.functions.Function<org.reactivestreams.Subscriber<? super R>,org.reactivestreams.Subscriber<? super T>> onLift)

Map the downstream Subscriber into an upstream Subscriber.

Type Parameters:
  `R` - the downstream value type
Parameters:
  `onLift` - the function called with the downstream's Subscriber and should return a Subscriber to be subscribed to this Perhaps.
Returns:
  the new Perhaps type

#### to

    public final <R> R to(io.reactivex.functions.Function<? super Perhaps<T>,R> converter)

Applies the function, fluently to this Perhaps and returns the value it returns.

Type Parameters:
  `R` - the result type
Parameters:
  `converter` - the function receiving this Perhaps and returns a value to be returned
Returns:
  the value returned by the function

#### compose

    public final <R> Perhaps<R> compose(io.reactivex.functions.Function<? super Perhaps<T>,? extends Perhaps<R>> composer)

Applies a function to this Perhaps and returns the Perhaps it returned.

Type Parameters:
  `R` - the result type
Parameters:
  `composer` - the function that receives this Perhaps and should return a Perhaps
Returns:
  the new Perhaps instance

#### takeUntil

    public final Perhaps<T> takeUntil(org.reactivestreams.Publisher<?> other)

Try consuming this Perhaps until the other Publisher signals an item or completes which then completes the Perhaps.

Parameters:
  `other` - the other Publisher instance
Returns:
  the new Perhaps instance

#### toFlowable

    public final io.reactivex.Flowable<T> toFlowable()

Convert this Perhaps into a Flowable.

Returns:
  the new Flowable instance

#### toObservable

    public final io.reactivex.Observable<T> toObservable()

Convert this Perhaps into an Observable.

Returns:
  the new Observable instance

#### toMaybe

    public final io.reactivex.Maybe<T> toMaybe()

Convert this Perhaps into a Maybe.

Returns:
  the new Maybe instance

#### cache

    public final Perhaps<T> cache()

Caches the value or error event of the upstream Perhaps and relays/replays it to Subscribers.

Returns:
  the new Perhaps instance
Since:
  0.14.1

#### subscribe

    public final void subscribe(org.reactivestreams.Subscriber<? super T> s)

Specified by:
  `subscribe` in interface `org.reactivestreams.Publisher<T>`

#### subscribeActual

    protected abstract void subscribeActual(org.reactivestreams.Subscriber<? super T> s)

Implement this method to react to a Subscriber subscribing to this Perhaps.

Parameters:
  `s` - the downstream Subscriber, never null

#### subscribeWith

    public final <E extends org.reactivestreams.Subscriber<? super T>> E subscribeWith(E s)

Subscribe with a Subscriber (subclass) and return it as is.

Type Parameters:
  `E` - the Subscriber subclass type
Parameters:
  `s` - the soubscriber, not null
Returns:
  the `s` as is

#### subscribe

    public final io.reactivex.disposables.Disposable subscribe()

Subscribe to this Perhaps and ignore any signal it produces.

Returns:
  the Disposable that allows cancelling the subscription

#### subscribe

    public final io.reactivex.disposables.Disposable subscribe(io.reactivex.functions.Consumer<? super T> onNext)

Subscribes to this Perhaps and calls the onNext if this Perhaps succeeds.

Parameters:
  `onNext` - called when this Perhaps succeeds
Returns:
  the Disposable that allows cancelling the subscription

#### subscribe

    public final io.reactivex.disposables.Disposable subscribe(io.reactivex.functions.Consumer<? super T> onNext,
                                                               io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)

Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.

Parameters:
  `onNext` - called when this Perhaps succeeds
  `onError` - called when this Perhaps fails
Returns:
  the Disposable that allows cancelling the subscription

#### subscribe

    public final io.reactivex.disposables.Disposable subscribe(io.reactivex.functions.Consumer<? super T> onNext,
                                                               io.reactivex.functions.Consumer<? super java.lang.Throwable> onError,
                                                               io.reactivex.functions.Action onComplete)

Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.

Parameters:
  `onNext` - called when this Perhaps succeeds
  `onError` - called when this Perhaps fails
  `onComplete` - called when this Perhaps succeeds after the call to onNext
Returns:
  the Disposable that allows cancelling the subscription

#### blockingSubscribe

    public final void blockingSubscribe()

Blocks until this Perhaps terminates and ignores the signals it produced.

#### blockingSubscribe

    public final void blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext)

Blocks until this Perhaps terminates and calls the onNext with the success value.

Parameters:
  `onNext` - the callback to call when this Perhaps completes with a success value

#### blockingSubscribe

    public final void blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext,
                                        io.reactivex.functions.Consumer<? super java.lang.Throwable> onError)

Blocks until this Perhaps terminates and calls the onNext with the success value or calls the onError with the error Throwable.

Parameters:
  `onNext` - the callback to call when this Perhaps completes with a success value
  `onError` - the callback to call when this Perhaps fails with an error

#### blockingSubscribe

    public final void blockingSubscribe(io.reactivex.functions.Consumer<? super T> onNext,
                                        io.reactivex.functions.Consumer<? super java.lang.Throwable> onError,
                                        io.reactivex.functions.Action onComplete)

Blocks until this Perhaps produces its terminal signal and calls the appropriate callback(s) based on the signal type.

Parameters:
  `onNext` - called when the Perhaps succeeds
  `onError` - called when the Perhaps fails
  `onComplete` - called when the Perhaps succeeds after the call to onNext.

#### blockingGet

    public final T blockingGet()

Blockingly awaits indefinitely the success value of this Perhaps or rethrows its error (wrapped into a RuntimeException if necessary).

Returns:
  the success value of this Perhaps

#### blockingGet

    public final T blockingGet(long timeout,
                               java.util.concurrent.TimeUnit unit)

Blockingly awaits at most the given timeout for the success value of this Perhaps or rethrows its error (wrapped into a RuntimeException if necessary).

Parameters:
  `timeout` - the time to wait for a success value
  `unit` - the time unit of the timeout
Returns:
  the success value of this Perhaps

#### test

    public final io.reactivex.subscribers.TestSubscriber<T> test()

Creates a TestSubscriber and subscribes it to this Perhaps.

Returns:
  the new TestSubscriber instance

#### test

    public final io.reactivex.subscribers.TestSubscriber<T> test(boolean cancel)

Creates a TestSubscriber, optionally cancels it, and subscribes it to this Perhaps.

Parameters:
  `cancel` - if true, the TestSubscriber will be cancelled before subscribing to this Perhaps
Returns:
  the new TestSubscriber instance

#### test

    public final io.reactivex.subscribers.TestSubscriber<T> test(long initialRequest)

Creates a TestSubscriber with the given initial request and subscribes it to this Perhaps.

Parameters:
  `initialRequest` - the initial request amount, non-negative
Returns:
  the new TestSubscriber

#### test

    public final io.reactivex.subscribers.TestSubscriber<T> test(long initialRequest,
                                                                 boolean cancel)

Creates a TestSubscriber with the given initial request, optionally cancels it, and subscribes it to this Perhaps.

Parameters:
  `initialRequest` - the initial request amount, non-negative
  `cancel` - if true, the TestSubscriber will be cancelled before subscribing to this Perhaps
Returns:
  the new TestSubscriber

#### toFuture

    public final java.util.concurrent.Future<T> toFuture()

Converts this Perhaps into a Future and signals its single value or null if this Perhaps is empty.

Returns:
  the new Future instance