Skip to content

Commit f20fd87

Browse files
authored
3.x: Add Maybe marble diagrams (14 cases) (#6730)
1 parent a92a357 commit f20fd87

File tree

1 file changed

+47
-27
lines changed

1 file changed

+47
-27
lines changed

src/main/java/io/reactivex/rxjava3/core/Maybe.java

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,13 +1817,13 @@ public static <T> Maybe<T> wrap(MaybeSource<T> source) {
18171817
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
18181818
* items emitted, in sequence, by an Iterable of other MaybeSources.
18191819
* <p>
1820+
* <img width="640" height="341" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.i.png" alt="">
1821+
* <p>
18201822
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the
18211823
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a
18221824
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
1823-
*
18241825
* <p>
1825-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
1826-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
1826+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
18271827
* also means it is possible some sources may not get subscribed to at all.
18281828
* <dl>
18291829
* <dt><b>Scheduler:</b></dt>
@@ -1853,8 +1853,9 @@ public static <T, R> Maybe<R> zip(Iterable<? extends MaybeSource<? extends T>> s
18531853
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
18541854
* two items emitted, in sequence, by two other MaybeSources.
18551855
* <p>
1856-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
1857-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
1856+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
1857+
* <p>
1858+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
18581859
* also means it is possible some sources may not get subscribed to at all.
18591860
* <dl>
18601861
* <dt><b>Scheduler:</b></dt>
@@ -1890,8 +1891,9 @@ public static <T1, T2, R> Maybe<R> zip(
18901891
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
18911892
* three items emitted, in sequence, by three other MaybeSources.
18921893
* <p>
1893-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
1894-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
1894+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
1895+
* <p>
1896+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
18951897
* also means it is possible some sources may not get subscribed to at all.
18961898
* <dl>
18971899
* <dt><b>Scheduler:</b></dt>
@@ -1931,8 +1933,9 @@ public static <T1, T2, T3, R> Maybe<R> zip(
19311933
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
19321934
* four items emitted, in sequence, by four other MaybeSources.
19331935
* <p>
1934-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
1935-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
1936+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
1937+
* <p>
1938+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
19361939
* also means it is possible some sources may not get subscribed to at all.
19371940
* <dl>
19381941
* <dt><b>Scheduler:</b></dt>
@@ -1977,8 +1980,9 @@ public static <T1, T2, T3, T4, R> Maybe<R> zip(
19771980
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
19781981
* five items emitted, in sequence, by five other MaybeSources.
19791982
* <p>
1980-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
1981-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
1983+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
1984+
* <p>
1985+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
19821986
* also means it is possible some sources may not get subscribed to at all.
19831987
* <dl>
19841988
* <dt><b>Scheduler:</b></dt>
@@ -2027,8 +2031,9 @@ public static <T1, T2, T3, T4, T5, R> Maybe<R> zip(
20272031
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
20282032
* six items emitted, in sequence, by six other MaybeSources.
20292033
* <p>
2030-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
2031-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
2034+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
2035+
* <p>
2036+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
20322037
* also means it is possible some sources may not get subscribed to at all.
20332038
* <dl>
20342039
* <dt><b>Scheduler:</b></dt>
@@ -2081,8 +2086,9 @@ public static <T1, T2, T3, T4, T5, T6, R> Maybe<R> zip(
20812086
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
20822087
* seven items emitted, in sequence, by seven other MaybeSources.
20832088
* <p>
2084-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
2085-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
2089+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
2090+
* <p>
2091+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
20862092
* also means it is possible some sources may not get subscribed to at all.
20872093
* <dl>
20882094
* <dt><b>Scheduler:</b></dt>
@@ -2140,8 +2146,9 @@ public static <T1, T2, T3, T4, T5, T6, T7, R> Maybe<R> zip(
21402146
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
21412147
* eight items emitted, in sequence, by eight other MaybeSources.
21422148
* <p>
2143-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
2144-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
2149+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
2150+
* <p>
2151+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
21452152
* also means it is possible some sources may not get subscribed to at all.
21462153
* <dl>
21472154
* <dt><b>Scheduler:</b></dt>
@@ -2203,14 +2210,14 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, R> Maybe<R> zip(
22032210
* Returns a Maybe that emits the results of a specified combiner function applied to combinations of
22042211
* nine items emitted, in sequence, by nine other MaybeSources.
22052212
* <p>
2206-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
2213+
* <img width="640" height="434" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zip.n.png" alt="">
2214+
* <p>
2215+
* This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
2216+
* also means it is possible some sources may not get subscribed to at all.
22072217
* <dl>
22082218
* <dt><b>Scheduler:</b></dt>
22092219
* <dd>{@code zip} does not operate by default on a particular {@link Scheduler}.</dd>
22102220
* </dl>
2211-
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
2212-
* also means it is possible some sources may not get subscribed to at all.
2213-
*
22142221
* @param <T1> the value type of the first source
22152222
* @param <T2> the value type of the second source
22162223
* @param <T3> the value type of the third source
@@ -2276,7 +2283,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Maybe<R> zip(
22762283
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
22772284
*
22782285
* <p>
2279-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
2286+
* <img width="640" height="341" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zipArray.png" alt="">
22802287
* <p>This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
22812288
* also means it is possible some sources may not get subscribed to at all.
22822289
* <dl>
@@ -2408,6 +2415,8 @@ public final Maybe<T> cache() {
24082415
/**
24092416
* Casts the success value of the current Maybe into the target type or signals a
24102417
* ClassCastException if not compatible.
2418+
* <p>
2419+
* <img width="640" height="318" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.cast.png" alt="">
24112420
* <dl>
24122421
* <dt><b>Scheduler:</b></dt>
24132422
* <dd>{@code cast} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2504,7 +2513,7 @@ public final Flowable<T> concatWith(MaybeSource<? extends T> other) {
25042513
* Returns a Single that emits a Boolean that indicates whether the source Maybe emitted a
25052514
* specified item.
25062515
* <p>
2507-
* <img width="640" height="320" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/contains.png" alt="">
2516+
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.contains.o.png" alt="">
25082517
* <dl>
25092518
* <dt><b>Scheduler:</b></dt>
25102519
* <dd>{@code contains} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2537,7 +2546,6 @@ public final Single<Boolean> contains(final Object item) {
25372546
* @return a Single that emits a single item: the number of items emitted by the source Maybe as a
25382547
* 64-bit Long item
25392548
* @see <a href="http://reactivex.io/documentation/operators/count.html">ReactiveX operators documentation: Count</a>
2540-
* @see #count()
25412549
*/
25422550
@CheckReturnValue
25432551
@SchedulerSupport(SchedulerSupport.NONE)
@@ -2585,6 +2593,7 @@ public final Single<T> defaultIfEmpty(T defaultItem) {
25852593
* the {@link TimeUnit} in which {@code period} is defined
25862594
* @return the new Maybe instance
25872595
* @see <a href="http://reactivex.io/documentation/operators/delay.html">ReactiveX operators documentation: Delay</a>
2596+
* @see #delay(long, TimeUnit, Scheduler)
25882597
*/
25892598
@CheckReturnValue
25902599
@SchedulerSupport(SchedulerSupport.COMPUTATION)
@@ -2654,6 +2663,8 @@ public final <U, V> Maybe<T> delay(Publisher<U> delayIndicator) {
26542663
/**
26552664
* Returns a Maybe that delays the subscription to this Maybe
26562665
* until the other Publisher emits an element or completes normally.
2666+
* <p>
2667+
* <img width="640" height="214" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.delaySubscription.p.png" alt="">
26572668
* <dl>
26582669
* <dt><b>Backpressure:</b></dt>
26592670
* <dd>The {@code Publisher} source is consumed in an unbounded fashion (without applying backpressure).</dd>
@@ -2679,7 +2690,7 @@ public final <U> Maybe<T> delaySubscription(Publisher<U> subscriptionIndicator)
26792690
/**
26802691
* Returns a Maybe that delays the subscription to the source Maybe by a given amount of time.
26812692
* <p>
2682-
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/delaySubscription.png" alt="">
2693+
* <img width="640" height="471" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.delaySubscription.t.png" alt="">
26832694
* <dl>
26842695
* <dt><b>Scheduler:</b></dt>
26852696
* <dd>This version of {@code delaySubscription} operates by default on the {@code computation} {@link Scheduler}.</dd>
@@ -2691,6 +2702,7 @@ public final <U> Maybe<T> delaySubscription(Publisher<U> subscriptionIndicator)
26912702
* the time unit of {@code delay}
26922703
* @return a Maybe that delays the subscription to the source Maybe by the given amount
26932704
* @see <a href="http://reactivex.io/documentation/operators/delay.html">ReactiveX operators documentation: Delay</a>
2705+
* @see #delaySubscription(long, TimeUnit, Scheduler)
26942706
*/
26952707
@CheckReturnValue
26962708
@SchedulerSupport(SchedulerSupport.COMPUTATION)
@@ -2702,7 +2714,7 @@ public final Maybe<T> delaySubscription(long delay, TimeUnit unit) {
27022714
* Returns a Maybe that delays the subscription to the source Maybe by a given amount of time,
27032715
* both waiting and subscribing on a given Scheduler.
27042716
* <p>
2705-
* <img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/delaySubscription.s.png" alt="">
2717+
* <img width="640" height="420" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.delaySubscription.ts.png" alt="">
27062718
* <dl>
27072719
* <dt><b>Scheduler:</b></dt>
27082720
* <dd>You specify which {@link Scheduler} this operator will use.</dd>
@@ -2884,6 +2896,8 @@ public final Maybe<T> doOnError(Consumer<? super Throwable> onError) {
28842896
* an onError or (null, null) for an onComplete signal from this Maybe before delivering said
28852897
* signal to the downstream.
28862898
* <p>
2899+
* <img width="640" height="297" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.doOnEvent.png" alt="">
2900+
* <p>
28872901
* Exceptions thrown from the callback will override the event so the downstream receives the
28882902
* error instead of the original signal.
28892903
* <dl>
@@ -3342,6 +3356,8 @@ public final Single<Boolean> isEmpty() {
33423356
* and providing a new {@code MaybeObserver}, containing the custom operator's intended business logic, that will be
33433357
* used in the subscription process going further upstream.
33443358
* <p>
3359+
* <img width="640" height="352" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.lift.png" alt="">
3360+
* <p>
33453361
* Generally, such a new {@code MaybeObserver} will wrap the downstream's {@code MaybeObserver} and forwards the
33463362
* {@code onSuccess}, {@code onError} and {@code onComplete} events from the upstream directly or according to the
33473363
* emission pattern the custom operator's business logic requires. In addition, such operator can intercept the
@@ -3862,6 +3878,8 @@ public final Maybe<T> onExceptionResumeNext(final MaybeSource<? extends T> next)
38623878
/**
38633879
* Nulls out references to the upstream producer and downstream MaybeObserver if
38643880
* the sequence is terminated or downstream calls dispose().
3881+
* <p>
3882+
* <img width="640" height="263" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.onTerminateDetach.png" alt="">
38653883
* <dl>
38663884
* <dt><b>Scheduler:</b></dt>
38673885
* <dd>{@code onTerminateDetach} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -4680,6 +4698,8 @@ public final <U> Maybe<T> timeout(Publisher<U> timeoutIndicator, MaybeSource<? e
46804698
/**
46814699
* Returns a Maybe which makes sure when a MaybeObserver disposes the Disposable,
46824700
* that call is propagated up on the specified scheduler.
4701+
* <p>
4702+
* <img width="640" height="700" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.unsubscribeOn.png" alt="">
46834703
* <dl>
46844704
* <dt><b>Scheduler:</b></dt>
46854705
* <dd>{@code unsubscribeOn} calls dispose() of the upstream on the {@link Scheduler} you specify.</dd>
@@ -4700,7 +4720,7 @@ public final Maybe<T> unsubscribeOn(final Scheduler scheduler) {
47004720
* Waits until this and the other MaybeSource signal a success value then applies the given BiFunction
47014721
* to those values and emits the BiFunction's resulting value to downstream.
47024722
*
4703-
* <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/zip.png" alt="">
4723+
* <img width="640" height="451" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Maybe.zipWith.png" alt="">
47044724
*
47054725
* <p>If either this or the other MaybeSource is empty or signals an error, the resulting Maybe will
47064726
* terminate immediately and dispose the other source.

0 commit comments

Comments
 (0)