public class BroadcastDispatcher<T> extends Object implements Dispatchable<T>
Every time dispatch(java.lang.reflect.Method, java.lang.Object[])
is invoked, all the broadcast targets will
see the same dispatch as well. The first target's return value is returned.
This enables a single listener to be converted into a multi-listener.
Constructor and Description |
---|
BroadcastDispatcher(Dispatchable<T>... dispatchTargets)
Create a broadcast dispatcher from the supplied dispatch targets.
|
Modifier and Type | Method and Description |
---|---|
Object |
dispatch(Method method,
Object[] args)
Dispatch the method and arguments to this object.
|
@SafeVarargs public BroadcastDispatcher(Dispatchable<T>... dispatchTargets)
dispatchTargets
- one or more targets to dispatch topublic Object dispatch(Method method, Object[] args) throws Throwable
Dispatchable
dispatch
in interface Dispatchable<T>
method
- a method defined in class T
args
- arguments corresponding to said method
method
Throwable
- any exception that might have been raised while invoking the method