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
ConstructorDescriptionInstantiationAwarePropertyAccessor
(T bean, Function<T, PersistentPropertyAccessor<T>> accessorFunction, EntityInstantiators instantiators) Creates anInstantiationAwarePropertyAccessor
using the given delegateaccessorFunction
andEntityInstantiators
. -
Method Summary
Modifier and TypeMethodDescriptiongetBean()
Returns the underlying bean.getProperty
(PersistentProperty<?> property) Returns the value of the givenPersistentProperty
of the underlying bean instance.void
setProperty
(PersistentProperty<?> property, Object value) Sets the givenPersistentProperty
to the given value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mapping.PersistentPropertyAccessor
getProperty, getProperty, setProperty
-
Constructor Details
-
InstantiationAwarePropertyAccessor
public InstantiationAwarePropertyAccessor(T bean, Function<T, PersistentPropertyAccessor<T>> accessorFunction, EntityInstantiators instantiators) Creates anInstantiationAwarePropertyAccessor
using the given delegateaccessorFunction
andEntityInstantiators
.accessorFunction
is used to obtain a newPersistentPropertyAccessor
for 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:PersistentPropertyAccessor
Sets the givenPersistentProperty
to the given value. Will do type conversion if aConversionService
is configured.- Specified by:
setProperty
in interfacePersistentPropertyAccessor<T>
- Parameters:
property
- must not be null.value
- can be null.
-
getProperty
Description copied from interface:PersistentPropertyAccessor
Returns the value of the givenPersistentProperty
of the underlying bean instance.- Specified by:
getProperty
in interfacePersistentPropertyAccessor<T>
- Parameters:
property
- must not be null.- Returns:
- can be null.
-
getBean
Description copied from interface:PersistentPropertyAccessor
Returns the underlying bean. The actual instance may change betweenPersistentPropertyAccessor.setProperty(PersistentProperty, Object)
calls.- Specified by:
getBean
in interfacePersistentPropertyAccessor<T>
- Returns:
- will never be null.
-