Skip to content

1.2 preparation cleanup and Experimental/Beta/Deprecated adjustments #4549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/rx/AsyncEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* <p>
* The onNext, onError and onCompleted methods should be called
* in a sequential manner, just like the Observer's methods. The
* other methods are threadsafe.
* other methods are thread-safe.
*
* @param <T> the value type to emit
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
Expand All @@ -48,7 +48,7 @@ public interface AsyncEmitter<T> extends Observer<T> {
void setCancellation(Cancellable c);
/**
* The current outstanding request amount.
* <p>This method it threadsafe.
* <p>This method it thread-safe.
* @return the current outstanding request amount
*/
long requested();
Expand Down Expand Up @@ -81,7 +81,7 @@ enum BackpressureMode {
*/
ERROR,
/**
* Buffers (unbounded) all onNext calls until the dowsntream can consume them.
* Buffers (unbounded) all onNext calls until the downstream can consume them.
*/
BUFFER,
/**
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/rx/BackpressureOverflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package rx;

import rx.annotations.Experimental;
import rx.annotations.Beta;
import rx.exceptions.MissingBackpressureException;

/**
* Generic strategy and default implementations to deal with backpressure buffer overflows.
*
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
*/
@Experimental
@Beta
public final class BackpressureOverflow {

/**
Expand Down Expand Up @@ -55,7 +57,7 @@ public interface Strategy {
* drop the item currently causing backpressure.
*
* @return true to request drop of the oldest item, false to drop the newest.
* @throws MissingBackpressureException
* @throws MissingBackpressureException if the strategy should signal MissingBackpressureException
*/
boolean mayAttemptDrop() throws MissingBackpressureException;
}
Expand Down
213 changes: 7 additions & 206 deletions src/main/java/rx/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,35 @@
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

import rx.annotations.Experimental;
import rx.annotations.*;
import rx.exceptions.*;
import rx.functions.*;
import rx.internal.operators.*;
import rx.internal.util.*;
import rx.observers.*;
import rx.plugins.*;
import rx.plugins.RxJavaHooks;
import rx.schedulers.Schedulers;
import rx.subscriptions.*;

/**
* Represents a deferred computation without any value but only indication for completion or exception.
*
* The class follows a similar event pattern as Reactive-Streams: onSubscribe (onError|onComplete)?
*
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
*/
@Experimental
@Beta
public class Completable {
/** The actual subscription action. */
private final OnSubscribe onSubscribe;

/**
* @deprecated Use {@link OnSubscribe} instead.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public interface CompletableOnSubscribe extends Action1<CompletableSubscriber> {

}

private static OnSubscribe fromOldOnSubscribe(final CompletableOnSubscribe onSubscribe) {
return new OnSubscribe() {
@Override
public void call(final rx.CompletableSubscriber s) {
onSubscribe.call(toOldSubscriber(s));
}
};
}

/**
* Callback used for building deferred computations that takes a CompletableSubscriber.
*/
public interface OnSubscribe extends Action1<rx.CompletableSubscriber> {

}

/**
* @deprecated Use {@link Operator} instead.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public interface CompletableOperator extends Func1<CompletableSubscriber, CompletableSubscriber> {

}

private static Operator fromOldOperator(final CompletableOperator operator) {
requireNonNull(operator);
return new Operator() {
@Override
public rx.CompletableSubscriber call(final rx.CompletableSubscriber subscriber) {
return fromOldSubscriber(operator.call(toOldSubscriber(subscriber)));
}
};
}

/**
* Convenience interface and callback used by the lift operator that given a child CompletableSubscriber,
* return a parent CompletableSubscriber that does any kind of lifecycle-related transformations.
Expand All @@ -90,78 +57,6 @@ public interface Operator extends Func1<rx.CompletableSubscriber, rx.Completable

}

/**
* @deprecated Use {@link rx.CompletableSubscriber} instead.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public interface CompletableSubscriber {
/**
* Called once the deferred computation completes normally.
*/
void onCompleted();

/**
* Called once if the deferred computation 'throws' an exception.
* @param e the exception, not null.
*/
void onError(Throwable e);

/**
* Called once by the Completable to set a Subscription on this instance which
* then can be used to cancel the subscription at any time.
* @param d the Subscription instance to call dispose on for cancellation, not null
*/
void onSubscribe(Subscription d);
}

static rx.CompletableSubscriber fromOldSubscriber(final CompletableSubscriber subscriber) {
requireNonNull(subscriber);
return new rx.CompletableSubscriber() {
@Override
public void onCompleted() {
subscriber.onCompleted();
}

@Override
public void onError(Throwable e) {
subscriber.onError(e);
}

@Override
public void onSubscribe(Subscription d) {
subscriber.onSubscribe(d);
}
};
}

static CompletableSubscriber toOldSubscriber(final rx.CompletableSubscriber subscriber) {
requireNonNull(subscriber);
return new CompletableSubscriber() {
@Override
public void onCompleted() {
subscriber.onCompleted();
}

@Override
public void onError(Throwable e) {
subscriber.onError(e);
}

@Override
public void onSubscribe(Subscription d) {
subscriber.onSubscribe(d);
}
};
}

/**
* @deprecated Use {@link Transformer} instead.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public interface CompletableTransformer extends Transformer {

}

/**
* Convenience interface and callback used by the compose operator to turn a Completable into another
* Completable fluently.
Expand Down Expand Up @@ -456,17 +351,6 @@ public static Completable concat(Observable<? extends Completable> sources, int
return create(new CompletableOnSubscribeConcat(sources, prefetch));
}

/**
* Constructs a Completable instance by wrapping the given old onSubscribe callback.
* @param onSubscribe the old CompletableOnSubscribe instance to wrap
* @return a Completable instance
* @deprecated Use {@link #create(OnSubscribe)}.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public static Completable create(CompletableOnSubscribe onSubscribe) {
return create(fromOldOnSubscribe(onSubscribe));
}

/**
* Constructs a Completable instance by wrapping the given onSubscribe callback.
* @param onSubscribe the callback which will receive the CompletableSubscriber instances
Expand Down Expand Up @@ -1117,14 +1001,6 @@ protected Completable(OnSubscribe onSubscribe) {
this.onSubscribe = RxJavaHooks.onCreate(onSubscribe);
}

/**
* @deprecated Use {@link #Completable(OnSubscribe)}.
*/
@Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
protected Completable(CompletableOnSubscribe onSubscribe) {
this(fromOldOnSubscribe(onSubscribe));
}

/**
* Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
* hook.
Expand All @@ -1136,19 +1012,6 @@ protected Completable(OnSubscribe onSubscribe, boolean useHook) {
this.onSubscribe = useHook ? RxJavaHooks.onCreate(onSubscribe) : onSubscribe;
}

/**
* Constructs a Completable instance with the given onSubscribe callback without calling the onCreate
* hook.
* @param onSubscribe the callback that will receive CompletableSubscribers when they subscribe,
* not null (not verified)
* @param useHook if false, RxJavaHooks.onCreate won't be called
* @deprecated Use {@link #Completable(OnSubscribe, boolean)}.
*/
@Deprecated // TODO Remove constructor after 1.2.0 release. It was never a stable API. Provided only for migration.
protected Completable(CompletableOnSubscribe onSubscribe, boolean useHook) {
this(fromOldOnSubscribe(onSubscribe), useHook);
}

/**
* Returns a Completable that emits the a terminated event of either this Completable
* or the other Completable whichever fires first.
Expand Down Expand Up @@ -1422,17 +1285,6 @@ public void onSubscribe(Subscription d) {
});
}

/**
* Returns a Completable which calls the given onComplete callback if this Completable completes.
* @param onComplete the callback to call when this emits an onComplete event
* @return the new Completable instance
* @throws NullPointerException if onComplete is null
* @deprecated Use {@link #doOnCompleted(Action0)} instead.
*/
@Deprecated public final Completable doOnComplete(Action0 onComplete) {
return doOnCompleted(onComplete);
}

/**
* Returns a Completable which calls the given onCompleted callback if this Completable completes.
* @param onCompleted the callback to call when this emits an onComplete event
Expand Down Expand Up @@ -1599,34 +1451,6 @@ public void call(Throwable e) {
}, onTerminate, Actions.empty(), Actions.empty());
}

/**
* Returns a completable that first runs this Completable
* and then the other completable.
* <p>
* This is an alias for {@link #concatWith(Completable)}.
* @param other the other Completable, not null
* @return the new Completable instance
* @throws NullPointerException if other is null
* @deprecated Use {@link #andThen(rx.Completable)} instead.
*/
@Deprecated
public final Completable endWith(Completable other) {
return andThen(other);
}

/**
* Returns an Observable that first runs this Completable instance and
* resumes with the given next Observable.
* @param <T> the value type of the next Observable
* @param next the next Observable to continue
* @return the new Observable instance
* @deprecated Use {@link #andThen(rx.Observable)} instead.
*/
@Deprecated
public final <T> Observable<T> endWith(Observable<T> next) {
return andThen(next);
}

/**
* Returns a Completable instance that calls the given onAfterComplete callback after this
* Completable completes normally.
Expand Down Expand Up @@ -1730,18 +1554,6 @@ public void onSubscribe(Subscription d) {
return null;
}

/**
* Lifts a CompletableSubscriber transformation into the chain of Completables.
* @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
* @return the new Completable instance
* @throws NullPointerException if onLift is null
* @deprecated Use {@link #lift(Operator)}.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public final Completable lift(CompletableOperator onLift) {
return lift(fromOldOperator(onLift));
}

/**
* Lifts a CompletableSubscriber transformation into the chain of Completables.
* @param onLift the lifting function that transforms the child subscriber with a parent subscriber.
Expand Down Expand Up @@ -2200,22 +2012,11 @@ public void onSubscribe(Subscription d) {
return mad;
}

private static void deliverUncaughtException(Throwable e) {
static void deliverUncaughtException(Throwable e) {
Thread thread = Thread.currentThread();
thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
}

/**
* Subscribes the given CompletableSubscriber to this Completable instance.
* @param s the CompletableSubscriber, not null
* @throws NullPointerException if s is null
* @deprecated Use {@link #unsafeSubscribe(rx.CompletableSubscriber)}.
*/
@Deprecated // TODO Remove interface after 1.2.0 release. It was never a stable API. Provided only for migration.
public final void unsafeSubscribe(CompletableSubscriber s) {
unsafeSubscribe(fromOldSubscriber(s));
}

/**
* Subscribes the given CompletableSubscriber to this Completable instance.
* @param s the CompletableSubscriber, not null
Expand Down Expand Up @@ -2268,7 +2069,7 @@ public final <T> void unsafeSubscribe(final Subscriber<T> s) {
* @param callOnStart if true, the Subscriber.onStart will be called
* @throws NullPointerException if s is null
*/
private final <T> void unsafeSubscribe(final Subscriber<T> s, boolean callOnStart) {
private <T> void unsafeSubscribe(final Subscriber<T> s, boolean callOnStart) {
requireNonNull(s);
try {
if (callOnStart) {
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/rx/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static <T> Notification<T> createOnCompleted() {
* Creates and returns a {@code Notification} of variety {@code Kind.OnCompleted}.
*
* @param <T> the actual value type held by the Notification
* @param type
* @param type the type token to help with type inference of {@code <T>}
* @deprecated this method does the same as {@link #createOnCompleted()} and does not use the passed in type hence it's useless.
* @return an {@code OnCompleted} variety of {@code Notification}
*/
Expand Down Expand Up @@ -217,14 +217,7 @@ public boolean equals(Object obj) {
}

Notification<?> notification = (Notification<?>) obj;
if (notification.getKind() != getKind()) {
return false;
}

if (!(value == notification.value || (value != null && value.equals(notification.value)))) {
return false;
}
return notification.getKind() == getKind() && (value == notification.value || (value != null && value.equals(notification.value))) && (throwable == notification.throwable || (throwable != null && throwable.equals(notification.throwable)));

return (throwable == notification.throwable || (throwable != null && throwable.equals(notification.throwable)));
}
}
Loading