public class Functor extends Object
Functors may be defined for instance objects or classes.
The method is created on first use, which allows the invokee (class or instance) to be omitted from the constructor.
The class name takes precedence over the instance.
If a functor is created with a particular instance, then that is used for all future calls; if an object is provided, it is ignored. This allows easy override of the table model behaviour.
If an argument list is provided in the constructor, then that is ignored in subsequent invoke() calls.
Usage:
f = new Functor("methodName"); o = f.invoke(object); // - OR - o = f.invoke(object, params);
f2 = new Functor(object, "methodName"); o = f2.invoke(); // - OR - o = f2.invoke(params);
f3 = new Functor(class, "methodName"); o = f3.invoke(object); // - will be ignored o = f3.invoke(); // - OR - o = f3.invoke(params); o = f3.invoke(object, params); // - object will be ignored
Constructor and Description |
---|
Functor(Class<?> _clazz,
String _methodName)
Create a functor from class and method name.
|
Functor(Class<?> _clazz,
String _methodName,
Class<?>[] _types)
Create a functor with the class, method name, and argument class types.
|
Functor(Object _invokee,
String _methodName)
Create a functor with the invokee and a method name.
|
Functor(Object _invokee,
String _methodName,
Class<?>[] _types)
Create a functor with the invokee, method name, and argument class types.
|
Functor(Object _invokee,
String _methodName,
Object[] _args)
Create a functor with an invokee, method name, and argument values.
|
Functor(String _methodName)
Create a functor with just the method name.
|
Functor(String _methodName,
Class<?>[] _types)
Create a functor with the method name and argument class types.
|
Functor(String _methodName,
Object[] _args)
Create a functor from method name and arguments.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkMethod(Object _invokee)
Deprecated.
** for use by Unit test code only **
|
boolean |
checkMethod(Object _invokee,
Class<?> c)
Deprecated.
** for use by Unit test code only **
|
Object |
invoke()
Invoke a Functor, which must have been created with either a class name or object.
|
Object |
invoke(Object p_invokee)
Invoke the method on a given object.
|
Object |
invoke(Object[] p_args)
Invoke the method with the provided parameters.
|
Object |
invoke(Object p_invokee,
Object[] p_args)
Invoke the method on the invokee with the provided parameters.
|
String |
toString() |
public Functor(Object _invokee, String _methodName)
_invokee
- object on which to invoke the method_methodName
- method namepublic Functor(Class<?> _clazz, String _methodName)
_clazz
- class to be used_methodName
- method namepublic Functor(Object _invokee, String _methodName, Class<?>[] _types)
_invokee
- object on which to invoke the method_methodName
- method name_types
- types of arguments to be usedpublic Functor(Class<?> _clazz, String _methodName, Class<?>[] _types)
_clazz
- the class in which to find the method_methodName
- method name_types
- types of arguments to be usedpublic Functor(String _methodName)
_methodName
- method namepublic Functor(String _methodName, Class<?>[] _types)
_methodName
- method name_types
- parameter typespublic Functor(Object _invokee, String _methodName, Object[] _args)
_invokee
- object on which to invoke the method_methodName
- method name_args
- arguments to be passed to the methodpublic Functor(String _methodName, Object[] _args)
_methodName
- method name_args
- arguments to be usedpublic Object invoke()
public Object invoke(Object p_invokee)
p_invokee
- - provides the object to call; ignored if the class or object were provided to the constructorpublic Object invoke(Object[] p_args)
p_args
- parameters for the methodpublic Object invoke(Object p_invokee, Object[] p_args)
p_invokee
- invokee to use, if no class or invokee was provided at construction timep_args
- arguments to use@Deprecated public boolean checkMethod(Object _invokee)
_invokee
- instance on which the method should be testedtrue
if method exists@Deprecated public boolean checkMethod(Object _invokee, Class<?> c)
_invokee
- instance on which the method should be testedc
- type of parametertrue
if method existsCopyright © 1998-2019 Apache Software Foundation. All Rights Reserved.