T - the value typepublic class HybridSubject<T> extends java.util.Observable implements java.util.Observer, Subject<T,T>, CloseableObservable<T>
Note that since java-observer is not generic, update() calls are cast to type T and might cause ClassCastException in case the data traveling is incorrect.
If the reactive-observer receives an error or finish event, all sub-observers are notified and both kinds of observers are unregistered.
Note also that reactive-observers are not notified in registration order and mixed observer case, only the java-observers are notified in order after the notification of reactive-observers.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.ConcurrentMap<java.io.Closeable,Observer<? super T>> |
registry
The registration holder for the reactive-observers.
|
| Constructor and Description |
|---|
HybridSubject() |
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(Observer<? super T> observer)
Registers the reactive-observer with this observable.
|
void |
close() |
int |
countObservers() |
void |
deleteObserver(Observer<? super T> observer)
Deregisters all instances of the supplied observer.
|
void |
deleteObservers() |
void |
error(java.lang.Throwable ex)
An exception is received.
|
void |
finish()
No more values to expect.
|
void |
next(T value)
The next value is received.
|
void |
notifyObservers(java.lang.Object arg) |
protected java.util.List<Observer<? super T>> |
observers() |
java.io.Closeable |
register(java.util.Observer observer)
Registers a java-observer and returns a handle to it.
|
java.io.Closeable |
register(Observer<? super T> observer)
Registers an observer for the notification of Ts.
|
protected void |
unregister(java.io.Closeable handle)
Unregister the given observer by its handle.
|
void |
update(java.util.Observable o,
java.lang.Object arg) |
public void next(T value)
Observerpublic void notifyObservers(java.lang.Object arg)
notifyObservers in class java.util.Observablepublic void error(@Nonnull
java.lang.Throwable ex)
BaseObservererror in interface BaseObserverex - the exceptionpublic void finish()
BaseObserverfinish in interface BaseObserver@Nonnull protected java.util.List<Observer<? super T>> observers()
@Nonnull
public java.io.Closeable register(@Nonnull
Observer<? super T> observer)
Observableregister in interface Observable<T>observer - the observer of Ts or any supertype of itpublic java.io.Closeable register(@Nonnull
java.util.Observer observer)
The convenience method is to have symmetric means for both observer kinds to interact with this observable.
observer - the observer to registerprotected void unregister(@Nonnull
java.io.Closeable handle)
handle - the handle identifying the observerpublic void update(java.util.Observable o,
java.lang.Object arg)
public void deleteObservers()
deleteObservers in class java.util.Observablepublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic int countObservers()
countObservers in class java.util.Observablepublic void addObserver(@Nonnull
Observer<? super T> observer)
The convenience method is to have symmetric means for both observer kinds to interact with this observable.
observer - the reactive-observer to registerpublic void deleteObserver(@Nonnull
Observer<? super T> observer)
Note that reactive-registration allows multiple registration and deregistration for the same observer instance, which are treated independently whereas java-observable does not.
The convenience method is to have symmetric means for both observer kinds to interact with this observable.
observer - the reactive-observer to unregister