|
Coinjema 1.7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.coinjema.util.Functor<R>
public class Functor<R>
The functor allows an easy way to setup dynamic methods that can be passed around and efficiently invoked. The functor is easier to use than jdk Method objects as it will figure out where to find the method that you want to invoke. For instance, if you are calling a method with objects that extend the class type of the arguments to that method, Functor will still find the correct method to invoke.
Constructor Summary | |
---|---|
Functor()
|
|
Functor(Object invokee,
String methodName)
|
|
Functor(Object invokee,
String methodName,
Class... types)
|
|
Functor(Object invokee,
String methodName,
Object... args)
|
|
Functor(Object invokee,
String methodName,
Object[] args,
Class... types)
|
|
Functor(String methodName)
|
|
Functor(String methodName,
Class... types)
|
|
Functor(String methodName,
Class[] types,
Object[] args)
|
|
Functor(String methodName,
Object... args)
|
|
Functor(String methodName,
String oneArg)
|
Method Summary | |
---|---|
R |
call()
|
Method |
createMethod(Object invokee,
Class... types)
|
String |
getMethodName()
|
R |
invoke()
|
R |
invoke(Object invokee,
Object... args)
|
R |
invokeOn(Object invokee)
|
R |
invokeWith(Object... args)
|
Functor<R> |
postChain(Functor<R> f)
If a post chain is added to a functor, then the chained functor will be run on the resulting object of this functor. |
Functor<R> |
postChain(Object invokee,
String methodName)
|
Functor<R> |
postChain(String methodName)
|
Functor<R> |
preChain(Functor<?> f)
If a pre chain is added to a functor, then the chained functor will be run and the results passed into this functor to invoke on. |
Functor |
preChain(Object invokee,
String methodName)
|
Functor |
preChain(Object invokee,
String methodName,
Object... args)
|
Functor |
preChain(String methodName)
|
Functor |
preChain(String methodName,
Object... args)
|
void |
run()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Functor()
public Functor(Object invokee, String methodName)
public Functor(Object invokee, String methodName, Class... types)
public Functor(String methodName)
public Functor(String methodName, Class... types)
public Functor(String methodName, Class[] types, Object[] args)
public Functor(String methodName, Object... args)
public Functor(String methodName, String oneArg)
public Functor(Object invokee, String methodName, Object... args)
public Functor(Object invokee, String methodName, Object[] args, Class... types)
Method Detail |
---|
public void run()
run
in interface Runnable
public R invoke(Object invokee, Object... args)
invoke
in interface InvokableOn<R>
public R call()
call
in interface Callable<R>
public R invokeOn(Object invokee)
invokeOn
in interface InvokableOn<R>
public R invokeWith(Object... args)
invokeWith
in interface InvokableWith<R>
public R invoke()
invoke
in interface Invokable<R>
public Method createMethod(Object invokee, Class... types)
public String getMethodName()
public Functor<R> postChain(Functor<R> f)
Ie: Assume, Functor A, Functor B,Functor C.
Given: A.postChain(B).postChain(C)
A.invokeOn(myObj) is equivalent to
C.invokeOn(B.invokeOn(A.invokeOn(myObj)))
A.invokeWith(objArray) is equivalent to
C.invokeOn(B.invokeOn(A.invokeWith(objArray)))
f
- public Functor<R> postChain(String methodName)
public Functor<R> postChain(Object invokee, String methodName)
public Functor<R> preChain(Functor<?> f)
Ie: Assume, Functor A, Functor B,Functor C.
Given: A.preChain(B).preChain(C)
A.invoke() is equivalent to A.invoke(B.invoke(C.invoke()))
A.invokeWith(objArray) is equivalent to
A.invokeWith(B.invoke(C.invoke()),objArray)
A.invokeOn(invokee) is equivalent to A.invokeOn(invokee,new
Object[]{B.invoke(C.invoke())})
f
- public Functor preChain(String methodName)
public Functor preChain(String methodName, Object... args)
public Functor preChain(Object invokee, String methodName)
public Functor preChain(Object invokee, String methodName, Object... args)
|
Coinjema 1.7 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |