Class DirectFieldAccessor
- All Implemented Interfaces:
ConfigurablePropertyAccessor, PropertyAccessor, PropertyEditorRegistry, TypeConverter
ConfigurablePropertyAccessor implementation that directly accesses
instance fields. Allows for direct binding to fields instead of going through
JavaBean setters.
As of Spring 4.2, the vast majority of the BeanWrapper features have
been merged to AbstractPropertyAccessor, which means that property
traversal as well as collections and map access is now supported here as well.
A DirectFieldAccessor's default for the "extractOldValueForEditor" setting is "true", since a field can always be read without side effects.
- Since:
- 2.0
- Author:
- Juergen Hoeller, Stephane Nicoll
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractNestablePropertyAccessor
AbstractNestablePropertyAccessor.PropertyHandler, AbstractNestablePropertyAccessor.PropertyTokenHolder -
Field Summary
Fields inherited from interface PropertyAccessor
NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR -
Constructor Summary
ConstructorsModifierConstructorDescriptionDirectFieldAccessor(Object object) Create a new DirectFieldAccessor for the given object.protectedDirectFieldAccessor(Object object, String nestedPath, DirectFieldAccessor parent) Create a new DirectFieldAccessor for the given object, registering a nested path that the object is in. -
Method Summary
Modifier and TypeMethodDescriptionprotected NotWritablePropertyExceptioncreateNotWritablePropertyException(String propertyName) Create aNotWritablePropertyExceptionfor the specified property.protected @Nullable org.springframework.beans.DirectFieldAccessor.FieldPropertyHandlergetLocalPropertyHandler(String propertyName) Return aAbstractNestablePropertyAccessor.PropertyHandlerfor the specified localpropertyName.protected DirectFieldAccessornewNestedPropertyAccessor(Object object, String nestedPath) Create a new nested property accessor instance.Methods inherited from class AbstractNestablePropertyAccessor
convertForProperty, getAutoGrowCollectionLimit, getFinalPath, getNestedPath, getPropertyAccessorForPropertyPath, getPropertyHandler, getPropertyType, getPropertyTypeDescriptor, getPropertyValue, getPropertyValue, getRootClass, getRootInstance, getWrappedClass, getWrappedInstance, isReadableProperty, isWritableProperty, setAutoGrowCollectionLimit, setPropertyValue, setPropertyValue, setPropertyValue, setWrappedInstance, setWrappedInstance, toStringMethods inherited from class AbstractPropertyAccessor
isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setExtractOldValueForEditor, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuesMethods inherited from class TypeConverterSupport
convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessaryMethods inherited from class PropertyEditorRegistrySupport
copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, setDefaultEditorRegistrar, useConfigValueEditorsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ConfigurablePropertyAccessor
getConversionService, setConversionServiceMethods inherited from interface PropertyEditorRegistry
findCustomEditor, registerCustomEditor, registerCustomEditorMethods inherited from interface TypeConverter
convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary
-
Constructor Details
-
DirectFieldAccessor
Create a new DirectFieldAccessor for the given object.- Parameters:
object- the object wrapped by this DirectFieldAccessor
-
DirectFieldAccessor
Create a new DirectFieldAccessor for the given object, registering a nested path that the object is in.- Parameters:
object- the object wrapped by this DirectFieldAccessornestedPath- the nested path of the objectparent- the containing DirectFieldAccessor (must not benull)
-
-
Method Details
-
getLocalPropertyHandler
protected @Nullable org.springframework.beans.DirectFieldAccessor.FieldPropertyHandler getLocalPropertyHandler(String propertyName) Description copied from class:AbstractNestablePropertyAccessorReturn aAbstractNestablePropertyAccessor.PropertyHandlerfor the specified localpropertyName. Only used to reach a property available in the current context.- Specified by:
getLocalPropertyHandlerin classAbstractNestablePropertyAccessor- Parameters:
propertyName- the name of a local property- Returns:
- the handler for that property, or
nullif it has not been found
-
newNestedPropertyAccessor
Description copied from class:AbstractNestablePropertyAccessorCreate a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.- Specified by:
newNestedPropertyAccessorin classAbstractNestablePropertyAccessor- Parameters:
object- the object wrapped by this PropertyAccessornestedPath- the nested path of the object- Returns:
- the nested PropertyAccessor instance
-
createNotWritablePropertyException
Description copied from class:AbstractNestablePropertyAccessorCreate aNotWritablePropertyExceptionfor the specified property.- Specified by:
createNotWritablePropertyExceptionin classAbstractNestablePropertyAccessor
-