public static class Parameter.ParametersProcessor extends Object
Modifier and Type | Field and Description |
---|---|
(package private) HashMap<String,Field> |
definedParameters |
(package private) HashMap<Field,Object> |
fields |
(package private) HashMap<String,Object> |
params |
Constructor and Description |
---|
ParametersProcessor(Object obj) |
ParametersProcessor(Object obj,
Parameter... parameters) |
ParametersProcessor(Object obj,
Properties prop) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildFields(Object obj)
Find fields owning a DefineParameter annotation.
|
protected void |
buildParametersMap(Parameter... parameters)
Create a map "key -> value" for parameters.
|
protected void |
buildParametersMap(Properties prop) |
protected void |
callAfterSetTrigger(DefineParameter dp,
Field f,
Object value)
Call the afterSet trigger.
|
protected void |
callBeforeSetTrigger(DefineParameter dp,
Field f,
Object value)
Call the beforeSet trigger.
|
protected void |
callSetter(DefineParameter dp,
Field f,
Object value)
Call setter of a parameter.
|
protected void |
checkNonOptionalParameters()
Check if all non-optional parameters will receive a value.
|
protected void |
checkValue(DefineParameter dp,
Field f,
Object value)
Check is the value is valid according to the DefineParameter
annotation.
|
private void |
init(Object obj) |
void |
process()
Start the processing part.
|
protected void |
setValue(DefineParameter dp,
Field f,
Object value)
Set the value of a field according to a parameter.
|
HashMap<String,Field> definedParameters
public ParametersProcessor(Object obj)
public ParametersProcessor(Object obj, Properties prop)
public ParametersProcessor(Object obj, Parameter... parameters)
public void process() throws InvalidParameterException, MissingParameterException
setValue(DefineParameter, Field, Object)
). Finally, the method checks is no parameter remaining. In this
case, an InvalidParameterException is thrown.protected void buildFields(Object obj)
obj
- the object on which searching fields.protected void buildParametersMap(Parameter... parameters)
parameters
- parameters which will be used in the process part.protected void buildParametersMap(Properties prop)
protected void setValue(DefineParameter dp, Field f, Object value) throws InvalidParameterException
checkValue(DefineParameter, Field, Object)
).
Then, the beforeSet trigger is called (
callBeforeSetTrigger(DefineParameter, Field, Object)
).
Then, if 'setters' value is empty, value is simply assigned to the
field, else 'setter' is called (
callSetter(DefineParameter, Field, Object)
). Finally, the
afterSet trigger is called (
callAfterSetTrigger(DefineParameter, Field, Object)
).dp
- the DefineParameter annotation being set.f
- field associated to the annotation.value
- value which will be assigned to the field.InvalidParameterException
protected void checkValue(DefineParameter dp, Field f, Object value) throws InvalidParameterException
dp
- the DefineParameter annotation associated to the field.f
- the field.value
- the value.InvalidParameterException
protected void checkNonOptionalParameters() throws MissingParameterException
MissingParameterException
- a non-optional parameter does not receive its value.protected void callSetter(DefineParameter dp, Field f, Object value) throws InvalidParameterException
DefineParameter.setter()
is not empty. If arguments count of
the setter is 1, then the value is passed as argument. If count is 2,
then parameter name and value are passed as arguments. Else, a
InvalidParameterException is thrown.dp
- the DefineParameter annotation associated to the field.f
- the field.value
- the value.InvalidParameterException
protected void callBeforeSetTrigger(DefineParameter dp, Field f, Object value) throws InvalidParameterException
DefineParameter.beforeSet()
. If arguments
count of the method is 0, no argument is given. If 1, then the value
is given. If 2, then the parameter name and its value are given.
Else, throw an InvalidParameterException.dp
- the DefineParameter annotation associated to the field.f
- the field.value
- the value.InvalidParameterException
protected void callAfterSetTrigger(DefineParameter dp, Field f, Object value) throws InvalidParameterException
DefineParameter.afterSet()
. If arguments
count of the method is 0, no argument is given. If 1, then the value
is given. If 2, then the parameter name and its value are given.
Else, throw an InvalidParameterException.dp
- the DefineParameter annotation associated to the field.f
- the field.value
- the value.InvalidParameterException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses