public class ConvertingPropertyAccessor extends Object implements PersistentPropertyAccessor
PersistentPropertyAccessor
that potentially converts the value handed to
setProperty(PersistentProperty, Object)
to the type of the PersistentProperty
using a
ConversionService
. Exposes getProperty(PersistentProperty, Class)
to allow obtaining the value of a
property in a type the ConversionService
can convert the raw type to.Constructor and Description |
---|
ConvertingPropertyAccessor(PersistentPropertyAccessor accessor,
ConversionService conversionService)
Creates a new
ConvertingPropertyAccessor for the given delegate PersistentPropertyAccessor and
ConversionService . |
Modifier and Type | Method and Description |
---|---|
Object |
getBean()
Returns the underlying bean.
|
Object |
getProperty(PersistentProperty<?> property)
Returns the value of the given
PersistentProperty of the underlying bean instance. |
<T> T |
getProperty(PersistentProperty<?> property,
Class<T> targetType)
Returns the value of the given
PersistentProperty converted to the given type. |
void |
setProperty(PersistentProperty<?> property,
Object value)
Sets the given
PersistentProperty to the given value. |
public ConvertingPropertyAccessor(PersistentPropertyAccessor accessor, ConversionService conversionService)
ConvertingPropertyAccessor
for the given delegate PersistentPropertyAccessor
and
ConversionService
.accessor
- must not be null.conversionService
- must not be null.public void setProperty(PersistentProperty<?> property, Object value)
PersistentPropertyAccessor
PersistentProperty
to the given value. Will do type conversion if a
ConversionService
is configured.setProperty
in interface PersistentPropertyAccessor
property
- must not be null.value
- can be null.public Object getProperty(PersistentProperty<?> property)
PersistentPropertyAccessor
PersistentProperty
of the underlying bean instance.getProperty
in interface PersistentPropertyAccessor
property
- must not be null.public <T> T getProperty(PersistentProperty<?> property, Class<T> targetType)
PersistentProperty
converted to the given type.property
- must not be null.targetType
- must not be null.public Object getBean()
PersistentPropertyAccessor
getBean
in interface PersistentPropertyAccessor
Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.