|
|||||||||
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.GetField<T,R>
public class GetField<T,R>
Unary Functor that returns the value of the named field for the argument. The field name and type are set at construction.
Copyright © 2002-2005 David A. Hall
Nested Class Summary | |
---|---|
static interface |
GetField.Visitor
Interface for classes that may interpret a GetField function. |
Constructor Summary | |
---|---|
GetField(java.lang.Class<T> argclass,
java.lang.reflect.Field field)
Builds a GetField for the given field |
|
GetField(java.lang.Class<T> argclass,
java.lang.String fieldName)
Builds a GetField for the given field, using the given class to find the desired field. |
|
GetField(java.lang.reflect.Field field)
Builds a GetField for the given field |
Method Summary | |
---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(GetField) field, if it
implements the nested Visitor interface. |
R |
fn(T arg)
Returns the value of the designated field of the argument |
java.lang.reflect.Field |
getField()
Lazily loads the Field object. |
java.lang.String |
getFieldName()
Returns the name of the field that this functor retrieves. |
java.lang.Class<R> |
getFieldType()
Returns the type of field that this functor retrieves. |
java.lang.Class<T> |
getObjectType()
Returns the class on which the field is retrieved. |
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 GetField(java.lang.reflect.Field field)
java.lang.IllegalArgumentException
- if the field is null, or is not a field
of the given classpublic GetField(java.lang.Class<T> argclass, java.lang.reflect.Field field)
java.lang.IllegalArgumentException
- if the field is null, or is not a field
of the given classpublic GetField(java.lang.Class<T> argclass, java.lang.String fieldName)
java.lang.IllegalArgumentException
- if the field name is null or empty,Method Detail |
---|
public java.lang.Class<T> getObjectType()
public java.lang.String getFieldName()
public java.lang.Class<R> getFieldType()
public java.lang.reflect.Field getField() throws java.lang.NoSuchFieldException
java.lang.NoSuchFieldException
public R fn(T arg)
fn
in class UnaryFunctor<T,R>
EvaluationException
- if the argument does not have the designated
public field, or if it is not of the correct type.public void accept(Visitor v)
visit(GetField)
field, 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 |