public class ReflectivePropertyAccessor extends Object implements PropertyAccessor
PropertyAccessor that uses reflection to access properties
 for reading and possibly also for writing.
 A property can be referenced through a public getter method (when being read) or a public setter method (when being written), and also as a public field.
StandardEvaluationContext, 
SimpleEvaluationContext, 
DataBindingPropertyAccessor| Modifier and Type | Class and Description | 
|---|---|
| static class  | ReflectivePropertyAccessor.OptimalPropertyAccessorAn optimized form of a PropertyAccessor that will use reflection but only knows
 how to access a particular property on a particular class. | 
| Constructor and Description | 
|---|
| ReflectivePropertyAccessor()Create a new property accessor for reading as well writing. | 
| ReflectivePropertyAccessor(boolean allowWrite)Create a new property accessor for reading and possibly writing. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | canRead(EvaluationContext context,
       Object target,
       String name)Called to determine if a resolver instance is able to access a specified property
 on a specified target object. | 
| boolean | canWrite(EvaluationContext context,
        Object target,
        String name)Called to determine if a resolver instance is able to write to a specified
 property on a specified target object. | 
| PropertyAccessor | createOptimalAccessor(EvaluationContext context,
                     Object target,
                     String name)Attempt to create an optimized property accessor tailored for a property of a
 particular name on a particular class. | 
| protected Field | findField(String name,
         Class<?> clazz,
         boolean mustBeStatic)Find a field of a certain name on a specified class. | 
| protected Method | findGetterForProperty(String propertyName,
                     Class<?> clazz,
                     boolean mustBeStatic)Find a getter method for the specified property. | 
| protected Method | findSetterForProperty(String propertyName,
                     Class<?> clazz,
                     boolean mustBeStatic)Find a setter method for the specified property. | 
| Member | getLastReadInvokerPair()Deprecated. 
 as of 4.3.15 since it is not used within the framework anymore | 
| protected String | getPropertyMethodSuffix(String propertyName)Return the method suffix for a given property name. | 
| protected String[] | getPropertyMethodSuffixes(String propertyName)Return the method suffixes for a given property name. | 
| Class<?>[] | getSpecificTargetClasses()Returns  nullwhich means this is a general purpose accessor. | 
| protected boolean | isCandidateForProperty(Method method,
                      Class<?> targetClass)Determine whether the given  Methodis a candidate for property access
 on an instance of the given target class. | 
| TypedValue | read(EvaluationContext context,
    Object target,
    String name)Called to read a property from a specified target object. | 
| void | write(EvaluationContext context,
     Object target,
     String name,
     Object newValue)Called to write to a property on a specified target object. | 
public ReflectivePropertyAccessor()
ReflectivePropertyAccessor(boolean)public ReflectivePropertyAccessor(boolean allowWrite)
allowWrite - whether to also allow for write operationscanWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)@Nullable public Class<?>[] getSpecificTargetClasses()
null which means this is a general purpose accessor.getSpecificTargetClasses in interface PropertyAccessornull if a general resolver)public boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException
PropertyAccessorcanRead in interface PropertyAccessorcontext - the evaluation context in which the access is being attemptedtarget - the target object upon which the property is being accessedname - the name of the property being accessedAccessException - if there is any problem determining whether the property can be readpublic TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException
PropertyAccessorPropertyAccessor.canRead(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String) also returns true.read in interface PropertyAccessorcontext - the evaluation context in which the access is being attemptedtarget - the target object upon which the property is being accessedname - the name of the property being accessedAccessException - if there is any problem accessing the property valuepublic boolean canWrite(EvaluationContext context, @Nullable Object target, String name) throws AccessException
PropertyAccessorcanWrite in interface PropertyAccessorcontext - the evaluation context in which the access is being attemptedtarget - the target object upon which the property is being accessedname - the name of the property being accessedAccessException - if there is any problem determining whether the
 property can be written topublic void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue) throws AccessException
PropertyAccessorPropertyAccessor.canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String) also returns true.write in interface PropertyAccessorcontext - the evaluation context in which the access is being attemptedtarget - the target object upon which the property is being accessedname - the name of the property being accessednewValue - the new value for the propertyAccessException - if there is any problem writing to the property value@Deprecated @Nullable public Member getLastReadInvokerPair()
@Nullable protected Method findGetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic)
@Nullable protected Method findSetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic)
protected boolean isCandidateForProperty(Method method, Class<?> targetClass)
Method is a candidate for property access
 on an instance of the given target class.
 The default implementation considers any method as a candidate, even for
 non-user-declared properties on the Object base class.
method - the Method to evaluatetargetClass - the concrete target class that is being introspectedprotected String[] getPropertyMethodSuffixes(String propertyName)
protected String getPropertyMethodSuffix(String propertyName)
@Nullable protected Field findField(String name, Class<?> clazz, boolean mustBeStatic)
public PropertyAccessor createOptimalAccessor(EvaluationContext context, @Nullable Object target, String name)
Note: An optimal accessor is currently only usable for read attempts. Do not call this method if you need a read-write accessor.