|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jga.fn.Functor<R> net.sf.jga.fn.UnaryFunctor<T,R> net.sf.jga.fn.property.InvokeNoArgMethod<T,R>
public class InvokeNoArgMethod<T,R>
Functor that invokes a no-arg method named at construction and returns the result or null if the result is void.
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 unless we add more arguments to the constructor.
Copyright © 2003-2005 David A. Hall
Nested Class Summary | |
---|---|
static interface |
InvokeNoArgMethod.Visitor
Interface for classes that may interpret a InvokeMethod function. |
Constructor Summary | |
---|---|
InvokeNoArgMethod(java.lang.Class<T> objClass,
java.lang.reflect.Method method)
Builds an InvokeNoArgMethod for the given method, which takes no arguments. |
|
InvokeNoArgMethod(java.lang.Class<T> objclass,
java.lang.String methName)
Builds a InvokeNoArgMethod for the given method, which takes no arguments. |
|
InvokeNoArgMethod(java.lang.reflect.Method method)
Builds an InvokeNoArgMethod for the given method, which takes no arguments. |
Method Summary | |
---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(InvokeMethod) method, if it
implements the nested Visitor interface. |
R |
fn(T obj)
Invokes the method on the given object, and returns the result. |
java.lang.reflect.Method |
getMethod()
Lazy loads the method |
java.lang.String |
getMethodName()
Returns the name of the property that this functor retrieves. |
java.lang.Class<T> |
getObjectType()
Returns the class which supplied the method is invoked. |
java.lang.Class<R> |
getReturnType()
Returns the type of the method |
java.lang.String |
toString()
|
Methods inherited from class net.sf.jga.fn.UnaryFunctor |
---|
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InvokeNoArgMethod(java.lang.Class<T> objclass, java.lang.String methName)
java.lang.IllegalArgumentException
- if the method name is null or emptypublic InvokeNoArgMethod(java.lang.reflect.Method method)
NOTE: this constructor has lower type-safety guarantee than the other constructors, in that the compiler cannot check that the method's declaring class is T. When a functor built by this constructor is evaluated, it will throw IllegalArgumentException if given an incompatible argument.
java.lang.IllegalArgumentException
- if the method is null or if it takes argumentspublic InvokeNoArgMethod(java.lang.Class<T> objClass, java.lang.reflect.Method method)
java.lang.IllegalArgumentException
- if the method or class is null; if the method is not supplied
by the given class; or if the method takes one or more argumentsMethod Detail |
---|
public java.lang.Class<T> getObjectType()
public java.lang.String getMethodName()
public java.lang.Class<R> getReturnType()
public java.lang.reflect.Method getMethod() throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
public R fn(T obj)
fn
in class UnaryFunctor<T,R>
EvaluationException
- if the argument does not have the designated
public property, or if it is not of the correct type.
java.lang.IllegalArgumentException
- if the argument is not of the correct
typepublic void accept(Visitor v)
visit(InvokeMethod)
method, if it
implements the nested Visitor interface.
accept
in interface Visitable
accept
in class Functor<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 |