spring-framework / org.springframework.beans / PropertyAccessor

PropertyAccessor

interface PropertyAccessor

Common interface for classes that can access named properties (such as bean properties of an object or fields in an object) Serves as base interface for BeanWrapper.

Author
Juergen Hoeller

Since
1.1

See Also
BeanWrapperPropertyAccessorFactory#forBeanPropertyAccessPropertyAccessorFactory#forDirectFieldAccess

Properties

NESTED_PROPERTY_SEPARATOR

static val NESTED_PROPERTY_SEPARATOR: String

Path separator for nested properties. Follows normal Java conventions: getFoo().getBar() would be "foo.bar".

NESTED_PROPERTY_SEPARATOR_CHAR

static val NESTED_PROPERTY_SEPARATOR_CHAR: Char

PROPERTY_KEY_PREFIX

static val PROPERTY_KEY_PREFIX: String

Marker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".

PROPERTY_KEY_PREFIX_CHAR

static val PROPERTY_KEY_PREFIX_CHAR: Char

PROPERTY_KEY_SUFFIX

static val PROPERTY_KEY_SUFFIX: String

Marker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".

PROPERTY_KEY_SUFFIX_CHAR

static val PROPERTY_KEY_SUFFIX_CHAR: Char

Functions

getPropertyType

abstract fun getPropertyType(propertyName: String): Class<*>

Determine the property type for the specified property, either checking the property descriptor or checking the value in case of an indexed or mapped element.

getPropertyTypeDescriptor

abstract fun getPropertyTypeDescriptor(propertyName: String): TypeDescriptor

Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.

getPropertyValue

abstract fun getPropertyValue(propertyName: String): Any

Get the current value of the specified property.

isReadableProperty

abstract fun isReadableProperty(propertyName: String): Boolean

Determine whether the specified property is readable.

Returns false if the property doesn't exist.

isWritableProperty

abstract fun isWritableProperty(propertyName: String): Boolean

Determine whether the specified property is writable.

Returns false if the property doesn't exist.

setPropertyValue

abstract fun setPropertyValue(propertyName: String, value: Any): Unit
abstract fun setPropertyValue(pv: PropertyValue): Unit

Set the specified value as current property value.

setPropertyValues

abstract fun setPropertyValues(map: MutableMap<*, *>): Unit

Perform a batch update from a Map.

Bulk updates from PropertyValues are more powerful: This method is provided for convenience. Behavior will be identical to that of the #setPropertyValues(PropertyValues) method.

abstract fun setPropertyValues(pvs: PropertyValues): Unit

The preferred way to perform a batch update.

Note that performing a batch update differs from performing a single update, in that an implementation of this class will continue to update properties if a recoverable error (such as a type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.

Does not allow unknown fields or invalid fields.

abstract fun setPropertyValues(pvs: PropertyValues, ignoreUnknown: Boolean): Unit

Perform a batch update with more control over behavior.

Note that performing a batch update differs from performing a single update, in that an implementation of this class will continue to update properties if a recoverable error (such as a type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.

abstract fun setPropertyValues(pvs: PropertyValues, ignoreUnknown: Boolean, ignoreInvalid: Boolean): Unit

Perform a batch update with full control over behavior.

Note that performing a batch update differs from performing a single update, in that an implementation of this class will continue to update properties if a recoverable error (such as a type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.