TFrom
- source dispatch type, whose methods with dispatch(java.lang.reflect.Method, java.lang.Object[])
will be calledT
- destination dispatch type, methods will be converted to the class of T
public class DuckTypingDispatcher<TFrom,T> extends Object implements Dispatchable<TFrom>
For example, if two types have identical method names and arguments, but are not subclasses/subinterfaces of each other, this dispatcher will allow calls to be made from one type to the other.
Constructor and Description |
---|
DuckTypingDispatcher(Dispatchable<T> target,
Class<T> targetClass)
Create a new duck typing dispatcher.
|
Modifier and Type | Method and Description |
---|---|
Object |
dispatch(Method method,
Object[] args)
Dispatch the method and arguments to this object.
|
public DuckTypingDispatcher(Dispatchable<T> target, Class<T> targetClass)
target
- destination dispatch type, methods will be redirected to this dispatchertargetClass
- destination dispatch class, methods will be converted to this class'spublic Object dispatch(Method method, Object[] args)
Dispatchable
dispatch
in interface Dispatchable<TFrom>
method
- a method defined in class T
args
- arguments corresponding to said method
method