2020import java .util .concurrent .*;
2121import java .util .concurrent .atomic .AtomicBoolean ;
2222
23- import rx .annotations .Experimental ;
23+ import rx .annotations .* ;
2424import rx .exceptions .*;
2525import rx .functions .*;
2626import rx .internal .operators .*;
2727import rx .internal .util .*;
2828import rx .observers .*;
29- import rx .plugins .* ;
29+ import rx .plugins .RxJavaHooks ;
3030import rx .schedulers .Schedulers ;
3131import rx .subscriptions .*;
3232
3333/**
3434 * Represents a deferred computation without any value but only indication for completion or exception.
3535 *
3636 * The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
37+ *
38+ * @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
3739 */
38- @ Experimental
40+ @ Beta
3941public class Completable {
4042 /** The actual subscription action. */
4143 private final OnSubscribe onSubscribe ;
4244
43- /**
44- * @deprecated Use {@link OnSubscribe} instead.
45- */
46- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
47- public interface CompletableOnSubscribe extends Action1 <CompletableSubscriber > {
48-
49- }
50-
51- private static OnSubscribe fromOldOnSubscribe (final CompletableOnSubscribe onSubscribe ) {
52- return new OnSubscribe () {
53- @ Override
54- public void call (final rx .CompletableSubscriber s ) {
55- onSubscribe .call (toOldSubscriber (s ));
56- }
57- };
58- }
59-
6045 /**
6146 * Callback used for building deferred computations that takes a CompletableSubscriber.
6247 */
6348 public interface OnSubscribe extends Action1 <rx .CompletableSubscriber > {
6449
6550 }
6651
67- /**
68- * @deprecated Use {@link Operator} instead.
69- */
70- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
71- public interface CompletableOperator extends Func1 <CompletableSubscriber , CompletableSubscriber > {
72-
73- }
74-
75- private static Operator fromOldOperator (final CompletableOperator operator ) {
76- requireNonNull (operator );
77- return new Operator () {
78- @ Override
79- public rx .CompletableSubscriber call (final rx .CompletableSubscriber subscriber ) {
80- return fromOldSubscriber (operator .call (toOldSubscriber (subscriber )));
81- }
82- };
83- }
84-
8552 /**
8653 * Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
8754 * return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
@@ -90,78 +57,6 @@ public interface Operator extends Func1<rx.CompletableSubscriber, rx.Completable
9057
9158 }
9259
93- /**
94- * @deprecated Use {@link rx.CompletableSubscriber} instead.
95- */
96- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
97- public interface CompletableSubscriber {
98- /**
99- * Called once the deferred computation completes normally.
100- */
101- void onCompleted ();
102-
103- /**
104- * Called once if the deferred computation 'throws' an exception.
105- * @param e the exception, not null.
106- */
107- void onError (Throwable e );
108-
109- /**
110- * Called once by the Completable to set a Subscription on this instance which
111- * then can be used to cancel the subscription at any time.
112- * @param d the Subscription instance to call dispose on for cancellation, not null
113- */
114- void onSubscribe (Subscription d );
115- }
116-
117- static rx .CompletableSubscriber fromOldSubscriber (final CompletableSubscriber subscriber ) {
118- requireNonNull (subscriber );
119- return new rx .CompletableSubscriber () {
120- @ Override
121- public void onCompleted () {
122- subscriber .onCompleted ();
123- }
124-
125- @ Override
126- public void onError (Throwable e ) {
127- subscriber .onError (e );
128- }
129-
130- @ Override
131- public void onSubscribe (Subscription d ) {
132- subscriber .onSubscribe (d );
133- }
134- };
135- }
136-
137- static CompletableSubscriber toOldSubscriber (final rx .CompletableSubscriber subscriber ) {
138- requireNonNull (subscriber );
139- return new CompletableSubscriber () {
140- @ Override
141- public void onCompleted () {
142- subscriber .onCompleted ();
143- }
144-
145- @ Override
146- public void onError (Throwable e ) {
147- subscriber .onError (e );
148- }
149-
150- @ Override
151- public void onSubscribe (Subscription d ) {
152- subscriber .onSubscribe (d );
153- }
154- };
155- }
156-
157- /**
158- * @deprecated Use {@link Transformer} instead.
159- */
160- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
161- public interface CompletableTransformer extends Transformer {
162-
163- }
164-
16560 /**
16661 * Convenience interface and callback used by the compose operator to turn a Completable into another
16762 * Completable fluently.
@@ -456,17 +351,6 @@ public static Completable concat(Observable<? extends Completable> sources, int
456351 return create (new CompletableOnSubscribeConcat (sources , prefetch ));
457352 }
458353
459- /**
460- * Constructs a Completable instance by wrapping the given old onSubscribe callback.
461- * @param onSubscribe the old CompletableOnSubscribe instance to wrap
462- * @return a Completable instance
463- * @deprecated Use {@link #create(OnSubscribe)}.
464- */
465- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
466- public static Completable create (CompletableOnSubscribe onSubscribe ) {
467- return create (fromOldOnSubscribe (onSubscribe ));
468- }
469-
470354 /**
471355 * Constructs a Completable instance by wrapping the given onSubscribe callback.
472356 * @param onSubscribe the callback which will receive the CompletableSubscriber instances
@@ -1117,14 +1001,6 @@ protected Completable(OnSubscribe onSubscribe) {
11171001 this .onSubscribe = RxJavaHooks .onCreate (onSubscribe );
11181002 }
11191003
1120- /**
1121- * @deprecated Use {@link #Completable(OnSubscribe)}.
1122- */
1123- @ Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1124- protected Completable (CompletableOnSubscribe onSubscribe ) {
1125- this (fromOldOnSubscribe (onSubscribe ));
1126- }
1127-
11281004 /**
11291005 * Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
11301006 * hook.
@@ -1136,19 +1012,6 @@ protected Completable(OnSubscribe onSubscribe, boolean useHook) {
11361012 this .onSubscribe = useHook ? RxJavaHooks .onCreate (onSubscribe ) : onSubscribe ;
11371013 }
11381014
1139- /**
1140- * Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
1141- * hook.
1142- * @param onSubscribe the callback that will receive CompletableSubscribers when they subscribe,
1143- * not null (not verified)
1144- * @param useHook if false, RxJavaHooks.onCreate won't be called
1145- * @deprecated Use {@link #Completable(OnSubscribe, boolean)}.
1146- */
1147- @ Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
1148- protected Completable (CompletableOnSubscribe onSubscribe , boolean useHook ) {
1149- this (fromOldOnSubscribe (onSubscribe ), useHook );
1150- }
1151-
11521015 /**
11531016 * Returns a Completable that emits the a terminated event of either this Completable
11541017 * or the other Completable whichever fires first.
@@ -1422,17 +1285,6 @@ public void onSubscribe(Subscription d) {
14221285 });
14231286 }
14241287
1425- /**
1426- * Returns a Completable which calls the given onComplete callback if this Completable completes.
1427- * @param onComplete the callback to call when this emits an onComplete event
1428- * @return the new Completable instance
1429- * @throws NullPointerException if onComplete is null
1430- * @deprecated Use {@link #doOnCompleted(Action0)} instead.
1431- */
1432- @ Deprecated public final Completable doOnComplete (Action0 onComplete ) {
1433- return doOnCompleted (onComplete );
1434- }
1435-
14361288 /**
14371289 * Returns a Completable which calls the given onCompleted callback if this Completable completes.
14381290 * @param onCompleted the callback to call when this emits an onComplete event
@@ -1599,34 +1451,6 @@ public void call(Throwable e) {
15991451 }, onTerminate , Actions .empty (), Actions .empty ());
16001452 }
16011453
1602- /**
1603- * Returns a completable that first runs this Completable
1604- * and then the other completable.
1605- * <p>
1606- * This is an alias for {@link #concatWith(Completable)}.
1607- * @param other the other Completable, not null
1608- * @return the new Completable instance
1609- * @throws NullPointerException if other is null
1610- * @deprecated Use {@link #andThen(rx.Completable)} instead.
1611- */
1612- @ Deprecated
1613- public final Completable endWith (Completable other ) {
1614- return andThen (other );
1615- }
1616-
1617- /**
1618- * Returns an Observable that first runs this Completable instance and
1619- * resumes with the given next Observable.
1620- * @param <T> the value type of the next Observable
1621- * @param next the next Observable to continue
1622- * @return the new Observable instance
1623- * @deprecated Use {@link #andThen(rx.Observable)} instead.
1624- */
1625- @ Deprecated
1626- public final <T > Observable <T > endWith (Observable <T > next ) {
1627- return andThen (next );
1628- }
1629-
16301454 /**
16311455 * Returns a Completable instance that calls the given onAfterComplete callback after this
16321456 * Completable completes normally.
@@ -1730,18 +1554,6 @@ public void onSubscribe(Subscription d) {
17301554 return null ;
17311555 }
17321556
1733- /**
1734- * Lifts a CompletableSubscriber transformation into the chain of Completables.
1735- * @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
1736- * @return the new Completable instance
1737- * @throws NullPointerException if onLift is null
1738- * @deprecated Use {@link #lift(Operator)}.
1739- */
1740- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
1741- public final Completable lift (CompletableOperator onLift ) {
1742- return lift (fromOldOperator (onLift ));
1743- }
1744-
17451557 /**
17461558 * Lifts a CompletableSubscriber transformation into the chain of Completables.
17471559 * @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
@@ -2200,22 +2012,11 @@ public void onSubscribe(Subscription d) {
22002012 return mad ;
22012013 }
22022014
2203- private static void deliverUncaughtException (Throwable e ) {
2015+ static void deliverUncaughtException (Throwable e ) {
22042016 Thread thread = Thread .currentThread ();
22052017 thread .getUncaughtExceptionHandler ().uncaughtException (thread , e );
22062018 }
22072019
2208- /**
2209- * Subscribes the given CompletableSubscriber to this Completable instance.
2210- * @param s the CompletableSubscriber, not null
2211- * @throws NullPointerException if s is null
2212- * @deprecated Use {@link #unsafeSubscribe(rx.CompletableSubscriber)}.
2213- */
2214- @ Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
2215- public final void unsafeSubscribe (CompletableSubscriber s ) {
2216- unsafeSubscribe (fromOldSubscriber (s ));
2217- }
2218-
22192020 /**
22202021 * Subscribes the given CompletableSubscriber to this Completable instance.
22212022 * @param s the CompletableSubscriber, not null
@@ -2268,7 +2069,7 @@ public final <T> void unsafeSubscribe(final Subscriber<T> s) {
22682069 * @param callOnStart if true, the Subscriber.onStart will be called
22692070 * @throws NullPointerException if s is null
22702071 */
2271- private final <T > void unsafeSubscribe (final Subscriber <T > s , boolean callOnStart ) {
2072+ private <T > void unsafeSubscribe (final Subscriber <T > s , boolean callOnStart ) {
22722073 requireNonNull (s );
22732074 try {
22742075 if (callOnStart ) {
0 commit comments