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

One global onCompleted object #816

Merged
merged 1 commit into from
Feb 5, 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
8 changes: 6 additions & 2 deletions rxjava-core/src/main/java/rx/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Notification<T> {
private final Throwable throwable;
private final T value;

private static final Notification<Void> ON_COMPLETED = new Notification<Void>(Kind.OnCompleted, null, null);

public static <T> Notification<T> createOnNext(T t) {
return new Notification<T>(Kind.OnNext, t, null);
}
Expand All @@ -34,12 +36,14 @@ public static <T> Notification<T> createOnError(Throwable e) {
return new Notification<T>(Kind.OnError, null, e);
}

@SuppressWarnings("unchecked")
public static <T> Notification<T> createOnCompleted() {
return new Notification<T>(Kind.OnCompleted, null, null);
return (Notification<T>) ON_COMPLETED;
}

@SuppressWarnings("unchecked")
public static <T> Notification<T> createOnCompleted(Class<T> type) {
return new Notification<T>(Kind.OnCompleted, null, null);
return (Notification<T>) ON_COMPLETED;
}

private Notification(Kind kind, T value, Throwable e) {
Expand Down