Class InstantiationAwarePropertyAccessor<T>
java.lang.Object
org.springframework.data.mapping.model.InstantiationAwarePropertyAccessor<T>
- All Implemented Interfaces:
PersistentPropertyAccessor<T>
public class InstantiationAwarePropertyAccessor<T>
extends Object
implements PersistentPropertyAccessor<T>
A
PersistentPropertyAccessor that will use an entity's
PersistenceCreator to create a new instance of it to apply a new value
for a given PersistentProperty. Will only be used if the PersistentProperty is to be applied on a
completely immutable entity type exposing a entity creator.- Since:
- 2.3
- Author:
- Oliver Drotbohm, Mark Paluch, Johannes Englmeier
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiationAwarePropertyAccessor(T bean, Function<T, PersistentPropertyAccessor<T>> accessorFunction, EntityInstantiators instantiators) Creates anInstantiationAwarePropertyAccessorusing the given delegateaccessorFunctionandEntityInstantiators. -
Method Summary
Modifier and TypeMethodDescriptiongetBean()Returns the underlying bean.getProperty(PersistentProperty<?> property) Returns the value of the givenPersistentPropertyof the underlying bean instance.voidsetProperty(PersistentProperty<?> property, Object value) Sets the givenPersistentPropertyto the given value.
-
Constructor Details
-
InstantiationAwarePropertyAccessor
public InstantiationAwarePropertyAccessor(T bean, Function<T, PersistentPropertyAccessor<T>> accessorFunction, EntityInstantiators instantiators) Creates anInstantiationAwarePropertyAccessorusing the given delegateaccessorFunctionandEntityInstantiators.accessorFunctionis used to obtain a newPersistentPropertyAccessorfor each property to set.- Parameters:
bean- must not be null.accessorFunction- must not be null.instantiators- must not be null.- Since:
- 2.4
-
-
Method Details
-
setProperty
Description copied from interface:PersistentPropertyAccessorSets the givenPersistentPropertyto the given value. Will do type conversion if aConversionServiceis configured.- Specified by:
setPropertyin interfacePersistentPropertyAccessor<T>- Parameters:
property- must not be null.value- can be null.
-
getProperty
Description copied from interface:PersistentPropertyAccessorReturns the value of the givenPersistentPropertyof the underlying bean instance.- Specified by:
getPropertyin interfacePersistentPropertyAccessor<T>- Parameters:
property- must not be null.- Returns:
- can be null.
-
getBean
Description copied from interface:PersistentPropertyAccessorReturns the underlying bean. The actual instance may change betweenPersistentPropertyAccessor.setProperty(PersistentProperty, Object)calls.- Specified by:
getBeanin interfacePersistentPropertyAccessor<T>- Returns:
- will never be null.
-