|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.adatagenerator.modifiers.BeanFieldModifier<F,R,S>
F - the field typeR - the bean typepublic class BeanFieldModifier<F,R,S extends R>
A BeanModifier that changes just one field in a bean. The field is accessed and modified by reflection.
| Field Summary | |
|---|---|
protected static Logger |
logger
|
| Constructor Summary | |
|---|---|
BeanFieldModifier(Class<R> beanClass,
String fieldNameStem,
ValueModifier<F> valueModifier)
Creates a field modifier that gets, modifies and sets a value for the specified field. |
|
BeanFieldModifier(String name,
String context,
Class<R> beanClass,
String fieldNameStem,
ValueModifier<F> valueModifier)
Creates a field modifier that gets, modifies and sets a value for the specified field. |
|
BeanFieldModifier(String name,
String context,
String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier)
Creates a field modifier that sets and gets a field value using the specified field accessor and mutator, respectively. |
|
| Method Summary | ||
|---|---|---|
int |
compareContexts(NamedInstance namedInstance)
Compares the context of this instance to the context of another instance using the context comparator of this
instance. |
|
int |
compareTo(NamedInstance namedInstance)
Compares this instance to another instance using the comparator of this instance. |
|
String |
getContext()
The context in which this instance is named. |
|
Comparator<String> |
getContextComparator()
|
|
protected Method |
getFieldAccessor()
|
|
protected Method |
getFieldMutator()
|
|
String |
getFieldNameStem()
|
|
Class<F> |
getFieldType()
|
|
String |
getName()
Implementing classes should return a name that will be comparable within some context |
|
Comparator<NamedInstance> |
getNamedInstanceComparator()
|
|
protected ValueModifier<F> |
getValueModifier()
|
|
S |
modifyBean(S bean)
Modifies the specified bean. |
|
static
|
modifyBean(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier,
R bean)
|
|
protected static
|
modifyBeanInternal(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier,
R bean)
|
|
protected static
|
validateArgs0(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator)
Preconditions to validateArgs1(String, Method, Method, ValueModifier). |
|
protected static
|
validateArgs1(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier)
Preconditions to #BeanFieldModifier(String, Method, Method, ValueModifier) and
modifyBean(String, Method, Method, ValueModifier, Object) |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Logger logger
| Constructor Detail |
|---|
public BeanFieldModifier(Class<R> beanClass,
String fieldNameStem,
ValueModifier<F> valueModifier)
beanClass - the bean typefieldNameStem - the field name, that is, stripped of any prefix such as
set, get or isvalueModifier - a non-null modifier consistent with the field accessor and
mutator
public BeanFieldModifier(String name,
String context,
Class<R> beanClass,
String fieldNameStem,
ValueModifier<F> valueModifier)
beanClass - the bean typefieldNameStem - the field name, that is, stripped of any prefix such as
set, get or isvalueModifier - a non-null modifier consistent with the field accessor and
mutator
public BeanFieldModifier(String name,
String context,
String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier)
name - the name of this modifier instancefieldNameStem - the field name, that is, stripped of any prefix such as
set, get or isfieldAccessor - the method used to get a field value of a beanfieldMutator - the method used to set a field value of a beanvalueModifier - a non-null modifier consistent with the field accessor and
mutator| Method Detail |
|---|
protected static <F> void validateArgs1(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier)
#BeanFieldModifier(String, Method, Method, ValueModifier) and
modifyBean(String, Method, Method, ValueModifier, Object)
protected static <F> void validateArgs0(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator)
validateArgs1(String, Method, Method, ValueModifier). Reused by
CompositeBeanFieldModifier.
protected Method getFieldAccessor()
protected Method getFieldMutator()
public Class<F> getFieldType()
public String getFieldNameStem()
protected ValueModifier<F> getValueModifier()
public S modifyBean(S bean)
throws ModificationException
BeanModifier
modifyBean in interface BeanModifier<S extends R>bean - the object to modify
ModificationException - if modification fails
public static <F,R> R modifyBean(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier,
R bean)
throws ModificationException
ModificationException
protected static <F,R> R modifyBeanInternal(String fieldNameStem,
Method fieldAccessor,
Method fieldMutator,
ValueModifier<F> valueModifier,
R bean)
throws ModificationException
ModificationExceptionpublic String getName()
NamedInstance
getName in interface NamedInstancepublic String getContext()
NamedInstanceNamedInstance.compareTo(NamedInstance) returns the same (non-zero)
value that is the result of comparing the contexts.
getContext in interface NamedInstancepublic int compareContexts(NamedInstance namedInstance)
NamedInstancecontext comparator of this
instance.
compareContexts in interface NamedInstancepublic Comparator<String> getContextComparator()
getContextComparator in interface NamedInstancepublic int compareTo(NamedInstance namedInstance)
NamedInstancecomparator of this instance.
compareTo in interface Comparable<NamedInstance>compareTo in interface NamedInstancepublic Comparator<NamedInstance> getNamedInstanceComparator()
getNamedInstanceComparator in interface NamedInstance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||