Class Functor
-
- All Implemented Interfaces:
public class FunctorImplements function call-backs.
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 Summary
Constructors Constructor Description Functor(Object _invokee, String _methodName)Create a functor with the invokee and a method name. Functor(Class<out Object> _clazz, String _methodName)Create a functor from class and method name. Functor(Object _invokee, String _methodName, Array<Class<out Object>> _types)Create a functor with the invokee, method name, and argument class types. Functor(Class<out Object> _clazz, String _methodName, Array<Class<out Object>> _types)Create a functor with the class, method name, and argument class types. Functor(String _methodName)Create a functor with just the method name. Functor(String _methodName, Array<Class<out Object>> _types)Create a functor with the method name and argument class types. Functor(Object _invokee, String _methodName, Array<Object> _args)Create a functor with an invokee, method name, and argument values. Functor(String _methodName, Array<Object> _args)Create a functor from method name and arguments.
-
Method Summary
Modifier and Type Method Description Objectinvoke()Invoke a Functor, which must have been created with either a class name or object. Objectinvoke(Object p_invokee)Invoke the method on a given object. Objectinvoke(Array<Object> p_args)Invoke the method with the provided parameters. Objectinvoke(Object p_invokee, Array<Object> p_args)Invoke the method on the invokee with the provided parameters. booleancheckMethod(Object _invokee)Check if a read Functor method is valid. booleancheckMethod(Object _invokee, Class<out Object> c)Check if a write Functor method is valid. StringtoString()-
-
Constructor Detail
-
Functor
Functor(Object _invokee, String _methodName)
Create a functor with the invokee and a method name.- Parameters:
_invokee- object on which to invoke the method_methodName- method name
-
Functor
Functor(Class<out Object> _clazz, String _methodName)
Create a functor from class and method name.- Parameters:
_clazz- class to be used_methodName- method name
-
Functor
Functor(Object _invokee, String _methodName, Array<Class<out Object>> _types)
Create a functor with the invokee, method name, and argument class types.- Parameters:
_invokee- object on which to invoke the method_methodName- method name_types- types of arguments to be used
-
Functor
Functor(Class<out Object> _clazz, String _methodName, Array<Class<out Object>> _types)
Create a functor with the class, method name, and argument class types.- Parameters:
_clazz- the class in which to find the method_methodName- method name_types- types of arguments to be used
-
Functor
Functor(String _methodName)
Create a functor with just the method name.- Parameters:
_methodName- method name
-
Functor
Functor(String _methodName, Array<Class<out Object>> _types)
Create a functor with the method name and argument class types.- Parameters:
_methodName- method name_types- parameter types
-
Functor
Functor(Object _invokee, String _methodName, Array<Object> _args)
Create a functor with an invokee, method name, and argument values.- Parameters:
_invokee- object on which to invoke the method_methodName- method name_args- arguments to be passed to the method
-
-
Method Detail
-
invoke
Object invoke()
Invoke a Functor, which must have been created with either a class name or object.
- Returns:
the object if any
-
invoke
Object invoke(Object p_invokee)
Invoke the method on a given object.
- Parameters:
p_invokee- - provides the object to call; ignored if the class or object were provided to the constructor- Returns:
the value
-
invoke
Object invoke(Array<Object> p_args)
Invoke the method with the provided parameters. The invokee must have been provided in the constructor.
- Parameters:
p_args- parameters for the method- Returns:
the value
-
invoke
Object invoke(Object p_invokee, Array<Object> p_args)
Invoke the method on the invokee with the provided parameters. The invokee must agree with the class (if any) provided at construction time. If the invokee was provided at construction time, then this invokee will be ignored. If actual arguments were provided at construction time, then arguments will be ignored.
- Parameters:
p_invokee- invokee to use, if no class or invokee was provided at construction timep_args- arguments to use- Returns:
result of invocation
-
checkMethod
@Deprecated() boolean checkMethod(Object _invokee)
Check if a read Functor method is valid.
- Parameters:
_invokee- instance on which the method should be tested- Returns:
trueif method exists
-
checkMethod
@Deprecated() boolean checkMethod(Object _invokee, Class<out Object> c)
Check if a write Functor method is valid.
- Parameters:
_invokee- instance on which the method should be testedc- type of parameter- Returns:
trueif method exists
-
-
-
-