Class PropertySetExecutor
java.lang.Object
org.apache.commons.jexl3.internal.introspection.AbstractExecutor
org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Set
org.apache.commons.jexl3.internal.introspection.PropertySetExecutor
- All Implemented Interfaces:
JexlPropertySet
Specialized executor to set a property in an object.
- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
AbstractExecutor.Get, AbstractExecutor.Method, AbstractExecutor.Set
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
The property.private static final int
Index of the first character of the set{p,P}roperty.protected final Class
<?> The property value class.Fields inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
method, objectClass, TRY_FAILED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PropertySetExecutor
(Class<?> clazz, Method method, String key, Object value) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertySetExecutor
discover
(Introspector is, Class<?> clazz, String property, Object value) Discovers a PropertySetExecutor.private static Method
discoverSet
(Introspector is, Class<?> clazz, String property, Object arg) Discovers the method for aJexlPropertySet
.Gets the property targeted by this executor.Method used to set the property value of an object.private static boolean
isEmptyArray
(Object arg) Checks whether an argument is an empty array.private static Method
lookupSetEmptyArray
(Introspector is, Class<?> clazz, String methodName) Finds an empty array property setter method bymethodName
.Attempts to reuse this JexlPropertySet, checking that it is compatible with the actual set of arguments.Methods inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
castInteger, castString, classOf, equals, equals, getMethod, getMethodName, getTargetClass, hashCode, initMarker, isAlive, isCacheable, makeArgs, tryFailed
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.jexl3.introspection.JexlPropertySet
isCacheable, tryFailed
-
Field Details
-
SET_START_INDEX
private static final int SET_START_INDEXIndex of the first character of the set{p,P}roperty.- See Also:
-
property
The property. -
valueClass
The property value class.
-
-
Constructor Details
-
PropertySetExecutor
Creates an instance.- Parameters:
clazz
- the class the set method applies tomethod
- the method called through this executorkey
- the key to use as 1st argument to the set methodvalue
- the value
-
-
Method Details
-
discover
public static PropertySetExecutor discover(Introspector is, Class<?> clazz, String property, Object value) Discovers a PropertySetExecutor.The method to be found should be named "set{P,p}property.
- Parameters:
is
- the introspectorclazz
- the class to find the get method fromproperty
- the property name to findvalue
- the value to assign to the property- Returns:
- the executor if found, null otherwise
-
discoverSet
Discovers the method for aJexlPropertySet
.The method to be found should be named "set{P,p}property. As a special case, any empty array will try to find a valid array-setting non-ambiguous method.
- Parameters:
is
- the introspectorclazz
- the class to find the get method fromproperty
- the name of the property to setarg
- the value to assign to the property- Returns:
- the method if found, null otherwise
-
isEmptyArray
Checks whether an argument is an empty array.- Parameters:
arg
- the argument- Returns:
- true if
arg
is an empty array
-
lookupSetEmptyArray
Finds an empty array property setter method bymethodName
.This checks only one method with that name accepts an array as sole parameter.
- Parameters:
is
- the introspectorclazz
- the class to find the get method frommethodName
- the method name to find- Returns:
- the sole method that accepts an array as parameter
-
getTargetProperty
Description copied from class:AbstractExecutor
Gets the property targeted by this executor.- Overrides:
getTargetProperty
in classAbstractExecutor
- Returns:
- the target property
-
invoke
public Object invoke(Object o, Object argument) throws IllegalAccessException, InvocationTargetException Description copied from interface:JexlPropertySet
Method used to set the property value of an object.- Parameters:
o
- Object on which the property setter will be called with the valueargument
- value to be set- Returns:
- the value returned from the set operation (impl specific)
- Throws:
IllegalAccessException
InvocationTargetException
-
tryInvoke
Description copied from interface:JexlPropertySet
Attempts to reuse this JexlPropertySet, checking that it is compatible with the actual set of arguments.- Parameters:
o
- the object to invoke the get uponidentifier
- the property key to getvalue
- the property value to set- Returns:
- the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.
-