|
|||||||||
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.BinaryFunctor<T,R,R> net.sf.jga.fn.property.SetField<T,R>
public class SetField<T,R>
Binary Functor that sets the named field of the first argument to the value. The field name and type are set at construction. The return value will be null.
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 field.
Copyright © 2002-2005 David A. Hall
Nested Class Summary | |
---|---|
static interface |
SetField.Visitor
Interface for classes that may interpret a SetField function. |
Constructor Summary | |
---|---|
SetField(java.lang.Class<T> argType,
java.lang.reflect.Field field)
Builds a SetField that will update the value of the given field |
|
SetField(java.lang.Class<T> argType,
java.lang.reflect.Field field,
java.lang.Class<R> fieldType)
Builds a SetField that will update the value of the given field |
|
SetField(java.lang.Class<T> argType,
java.lang.String fieldName,
java.lang.Class<R> fieldType)
Builds a SetField that will update the value of the named field of an instance of type argType. |
|
SetField(java.lang.reflect.Field field)
Builds a SetField that will update the value of the given field |
Method Summary | |
---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(etField) field, if it
implements the nested Visitor interface. |
R |
fn(T arg,
R val)
Sets the designated field of the argument to the given value and returns null. |
java.lang.String |
getFieldName()
Returns the name of the field that this functor sets. |
java.lang.String |
toString()
|
Methods inherited from class net.sf.jga.fn.BinaryFunctor |
---|
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth |
Methods inherited from class net.sf.jga.fn.Functor |
---|
composeNth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SetField(java.lang.reflect.Field field)
java.lang.IllegalArgumentException
- if either argument is omitted, or if
there is no such setter field in type argType.public SetField(java.lang.Class<T> argType, java.lang.reflect.Field field)
java.lang.IllegalArgumentException
- if either argument is omitted, or if
there is no such setter field in type argType.public SetField(java.lang.Class<T> argType, java.lang.reflect.Field field, java.lang.Class<R> fieldType)
java.lang.IllegalArgumentException
- if either argument is omitted, or if
there is no such setter field in type argType.public SetField(java.lang.Class<T> argType, java.lang.String fieldName, java.lang.Class<R> fieldType)
java.lang.IllegalArgumentException
- if either argument is omitted, or if
there is no such setter field in type argType.Method Detail |
---|
public java.lang.String getFieldName()
public R fn(T arg, R val)
fn
in class BinaryFunctor<T,R,R>
EvaluationException
- if the argument does not have the designated
public field, or if it is accept the given value.public void accept(Visitor v)
visit(etField)
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 |