Skip to content
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

Change void accept to boolean accept #1295

Merged
merged 1 commit into from
May 30, 2014
Merged
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
Original file line number Diff line number Diff line change
@@ -31,8 +31,6 @@
* It's implemented as a singleton to maintain some semblance of type safety that is completely
* non-existent.
*
* @author gscampbell
*
* @param <T>
*/
public final class NotificationLite<T> {
@@ -89,8 +87,7 @@ public Object completed() {
}

/**
* Create a lite onError notification. This call does new up an object to wrap the
* {@link Throwable} but since there should only be one of these the performance impact should
* Create a lite onError notification. This call does new up an object to wrap the {@link Throwable} but since there should only be one of these the performance impact should
* be small. Can be unwrapped and sent with the {@link #accept} method.
*
* @param e
@@ -106,25 +103,27 @@ public Object error(Throwable e) {
* @param o
* the {@link Observer} to call onNext, onCompleted or onError.
* @param n
* @return true if the n was a termination event
* @throws IllegalArgumentException
* if the notification is null.
* @throws NullPointerException
* if the {@link Observer} is null.
*/
@SuppressWarnings("unchecked")
public void accept(Observer<? super T> o, Object n) {
public boolean accept(Observer<? super T> o, Object n) {
if (n == ON_COMPLETED_SENTINEL) {
o.onCompleted();
} else
if (n == ON_NEXT_NULL_SENTINEL) {
return true;
} else if (n == ON_NEXT_NULL_SENTINEL) {
o.onNext(null);
} else
if (n != null) {
return false;
} else if (n != null) {
if (n.getClass() == OnErrorSentinel.class) {
o.onError(((OnErrorSentinel)n).e);
} else {
o.onNext((T)n);
o.onError(((OnErrorSentinel) n).e);
return true;
}
o.onNext((T) n);
return false;
} else {
throw new IllegalArgumentException("The lite notification can not be null");
}
@@ -139,8 +138,7 @@ public boolean isError(Object n) {
}

/**
* If there is custom logic that isn't as simple as call the right method on an {@link Observer}
* then this method can be used to get the {@link rx.Notification.Kind}
* If there is custom logic that isn't as simple as call the right method on an {@link Observer} then this method can be used to get the {@link rx.Notification.Kind}
*
* @param n
* @return the kind of the raw object