|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jga.fn.BinaryFunctor<T,java.lang.Object[],R>
net.sf.jga.fn.property.InvokeMethod<T,R>
public class InvokeMethod<T,R>
Functor that invokes a method described at construction and returns the result or null if the result is void. The arguments must be passed to the functor in an array, and the values must be assignable to the corresponding classes given at construction.
Note that declaring the return type incorrectly can result in ClassCastExceptions being thrown when the functor is invoked: the compiler cannot check the return type of a reflectively loaded method.
Copyright © 2003 David A. Hall
| Nested Class Summary | |
|---|---|
static interface |
InvokeMethod.Visitor
Interface for classes that may interpret a InvokeMethod function. |
| Constructor Summary | |
|---|---|
InvokeMethod(java.lang.Class<T> objClass,
java.lang.reflect.Method method)
Builds a InvokeMethod for a given method, using the given class to find the desired method. |
|
InvokeMethod(java.lang.Class<T> objClass,
java.lang.String methName,
java.lang.Class argtype)
Builds a InvokeMethod for a given method, using the given class to find the desired method. |
|
InvokeMethod(java.lang.Class<T> objClass,
java.lang.String methName,
java.lang.Class[] argtypes)
Builds a InvokeMethod for the given method, using the given class array to find the desired method. |
|
| Method Summary | |
|---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(InvokeMethod) method, if it
implements the nested Visitor interface. |
R |
fn(T obj,
java.lang.Object[] args)
Executes the function and returns the result. |
java.lang.String |
getMethodName()
Returns the name of the method that this functor invokes. |
java.lang.Class<R> |
getReturnType()
Returns the type of the method |
java.lang.String |
toString()
|
| Methods inherited from class net.sf.jga.fn.BinaryFunctor |
|---|
bind, bind1st, bind2nd, compose, compose, distribute, generate, generate1st, generate2nd |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public InvokeMethod(java.lang.Class<T> objClass,
java.lang.reflect.Method method)
java.lang.IllegalArgumentException - if the method name is null or empty, or
if the argument type array is null.
public InvokeMethod(java.lang.Class<T> objClass,
java.lang.String methName,
java.lang.Class argtype)
java.lang.IllegalArgumentException - if the method name is null or empty, or
if the argument type array is null.
public InvokeMethod(java.lang.Class<T> objClass,
java.lang.String methName,
java.lang.Class[] argtypes)
java.lang.IllegalArgumentException - if the method name is null or empty, or
if the argument type array is null.| Method Detail |
|---|
public java.lang.String getMethodName()
public java.lang.Class<R> getReturnType()
public R fn(T obj,
java.lang.Object[] args)
BinaryFunctor
fn in class BinaryFunctor<T,java.lang.Object[],R>public void accept(Visitor v)
visit(InvokeMethod) method, if it
implements the nested Visitor interface.
accept in interface Visitableaccept in class BinaryFunctor<T,java.lang.Object[],R>public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||