dsto.dfc.reflection
Class Delegate
java.lang.Object
dsto.dfc.reflection.Delegate
- All Implemented Interfaces:
- IDelegate, Runnable
public class Delegate
- extends Object
- implements IDelegate, Runnable
A delegate to a method in a class instance. Supports
semi-lambda-like ability to pre-specify some arguments at creation
for appending to the set called with invoke().
- Author:
- Matthew Phillips
Delegate
public Delegate(Object target,
String methodName)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
Delegate
public Delegate(Object target,
String methodName,
Object... args)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
Delegate
public Delegate(Object target,
String methodName,
Class... argTypes)
throws IllegalArgumentException
- Create a delegate by giving a name and an argument type list.
- Parameters:
target
- The target object.methodName
- The name of the method to call.argTypes
- The argument types of the method.
- Throws:
IllegalArgumentException
Delegate
public Delegate(Object target,
String methodName,
Class[] argTypes,
Object[] args)
throws IllegalArgumentException
- Create an instance, fully specifying method and argument list.
- Parameters:
target
- The target object.methodName
- The name of the method to call.argTypes
- The argument types of the method.args
- Any arguments to pre-specify.
- Throws:
IllegalArgumentException
toString
public String toString()
- Overrides:
toString
in class Object
target
public Object target()
run
public void run()
- Specified by:
run
in interface Runnable
invoke
public void invoke(Object... args)
throws InvokeException
- Call the method pointed to by the delegate with the default
parameter set.
- Specified by:
invoke
in interface IDelegate
- Parameters:
args
- The arguments.
- Throws:
InvokeException
- if a checked exception occurs.
Copyright © 2008 Commonwealth of Australia