public class HandlerDispatcher<T> extends Object implements Dispatchable<T>
Runnable
.
All calls will return immediately; functions with return values will return a default
value of null
, 0
, or false
where that value is legal.
Any exceptions thrown on the handler while trying to invoke a method will be re-thrown. Throwing checked exceptions on a handler which doesn't expect any checked exceptions to be thrown will result in "undefined" behavior (although in practice it is usually thrown as normal).
Constructor and Description |
---|
HandlerDispatcher(Dispatchable<T> dispatchTarget,
Handler handler)
Create a dispatcher that forwards it's dispatch calls by posting
them onto the
handler as a Runnable . |
Modifier and Type | Method and Description |
---|---|
Object |
dispatch(Method method,
Object[] args)
Dispatch the method and arguments to this object.
|
public HandlerDispatcher(Dispatchable<T> dispatchTarget, Handler handler)
handler
as a Runnable
.T
- the type of the element you want to wrap.dispatchTarget
- the destination whose method calls will be redirected into the handlerhandler
- all calls into dispatchTarget
will be posted onto this handlerpublic 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