Package org.springframework.data.mapping
Interface PersistentPropertyAccessor<T>
- All Known Subinterfaces:
PersistentPropertyPathAccessor<T>
- All Known Implementing Classes:
ConvertingPropertyAccessor
,InstantiationAwarePropertyAccessor
public interface PersistentPropertyAccessor<T>
Domain service to allow accessing and setting
PersistentProperty
s of an entity. Usually obtained through
PersistentEntity.getPropertyAccessor(Object)
. In case type conversion shall be applied on property access,
use a ConvertingPropertyAccessor
.
This service supports mutation for immutable classes by creating new object instances. These are managed as state of
PersistentPropertyAccessor
and must be obtained from getBean()
after processing all updates.
- Since:
- 1.10
- Author:
- Oliver Gierke, Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetBean()
Returns the underlying bean.getProperty
(PersistentProperty<?> property) Returns the value of the givenPersistentProperty
of the underlying bean instance.default Object
getProperty
(PersistentPropertyPath<? extends PersistentProperty<?>> path) Deprecated.default Object
getProperty
(PersistentPropertyPath<? extends PersistentProperty<?>> path, TraversalContext context) Deprecated.void
setProperty
(PersistentProperty<?> property, Object value) Sets the givenPersistentProperty
to the given value.default void
setProperty
(PersistentPropertyPath<? extends PersistentProperty<?>> path, Object value) Deprecated.since 2.3, usePersistentPropertyPathAccessor.setProperty(PersistentPropertyPath, Object)
instead.
-
Method Details
-
setProperty
Sets the givenPersistentProperty
to the given value. Will do type conversion if aConversionService
is configured.- Parameters:
property
- must not be null.value
- can be null.- Throws:
MappingException
- in case an exception occurred when setting the property value.
-
setProperty
@Deprecated default void setProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, @Nullable Object value) Deprecated.since 2.3, usePersistentPropertyPathAccessor.setProperty(PersistentPropertyPath, Object)
instead.Sets the given value for thePersistentProperty
pointed to by the givenPersistentPropertyPath
. The lookup of intermediate values must not yield null.- Parameters:
path
- must not be null or empty.value
- can be null.- Since:
- 2.1
-
getProperty
Returns the value of the givenPersistentProperty
of the underlying bean instance.- Parameters:
property
- must not be null.- Returns:
- can be null.
-
getProperty
@Deprecated @Nullable default Object getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path) Deprecated.since 2.3, usePersistentPropertyPathAccessor.getProperty(PersistentPropertyPath)
insteadReturn the value pointed to by the givenPersistentPropertyPath
. If the given path is empty, the wrapped bean is returned.- Parameters:
path
- must not be null.- Returns:
- Since:
- 2.1
-
getProperty
@Nullable @Deprecated default Object getProperty(PersistentPropertyPath<? extends PersistentProperty<?>> path, TraversalContext context) Deprecated.Return the value pointed to by the givenPersistentPropertyPath
. If the given path is empty, the wrapped bean is returned. On each path segment value lookup, the resulting value is post-processed by handlers registered on the givenTraversalContext
context. This can be used to unwrap container types that are encountered during the traversal.- Parameters:
path
- must not be null.context
- must not be null.- Returns:
- Since:
- 2.2
-
getBean
T getBean()Returns the underlying bean. The actual instance may change betweensetProperty(PersistentProperty, Object)
calls.- Returns:
- will never be null.
-
PersistentPropertyPathAccessor.getProperty(PersistentPropertyPath)
instead