Package org.springframework.data.convert
Class SimplePropertyValueConversions
java.lang.Object
org.springframework.data.convert.SimplePropertyValueConversions
- All Implemented Interfaces:
InitializingBean
,PropertyValueConversions
public class SimplePropertyValueConversions
extends Object
implements PropertyValueConversions, InitializingBean
PropertyValueConversions
implementation that allows to pick a PropertyValueConverterFactory
serving
converters
. Activating cahing
allows to
reuse converters. Providing a SimplePropertyValueConverterRegistry
adds path configured converter instances.
Should be initialized
. If not, init()
will be called of fist attempt of
converter
retrieval.
- Since:
- 2.7
- Author:
- Christoph Strobl
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
<DV,
SV, C extends PersistentProperty<C>, D extends ValueConversionContext<C>>
PropertyValueConverter<DV,SV, D> getValueConverter
(C property) Get thePropertyValueConverter
for the given property.Get theValueConverterRegistry
used for path configured converters.boolean
hasValueConverter
(PersistentProperty<?> property) Check if aPropertyValueConverter
is present for the given property.void
init()
May be called just once to initialize the underlying factory with its values.void
setConverterCacheEnabled
(boolean converterCacheEnabled) Dis-/Enable caching.void
setConverterFactory
(PropertyValueConverterFactory converterFactory) void
setValueConverterRegistry
(ValueConverterRegistry<?> valueConverterRegistry) Set theconverter registry
for path configured converters.
-
Constructor Details
-
SimplePropertyValueConversions
public SimplePropertyValueConversions()
-
-
Method Details
-
setConverterFactory
- Parameters:
converterFactory
- must not be null.
-
getConverterFactory
-
setValueConverterRegistry
Set theconverter registry
for path configured converters. This is short for adding aPropertyValueConverterFactories.ConfiguredInstanceServingValueConverterFactory
at the end of aPropertyValueConverterFactories.ChainedPropertyValueConverterFactory
.- Parameters:
valueConverterRegistry
- must not be null.
-
getValueConverterRegistry
Get theValueConverterRegistry
used for path configured converters.- Returns:
- can be null.
-
setConverterCacheEnabled
public void setConverterCacheEnabled(boolean converterCacheEnabled) Dis-/Enable caching. Enabled by default.- Parameters:
converterCacheEnabled
- set to true to enable caching ofconverter
instances.
-
hasValueConverter
Description copied from interface:PropertyValueConversions
Check if aPropertyValueConverter
is present for the given property.- Specified by:
hasValueConverter
in interfacePropertyValueConversions
- Parameters:
property
- must not be null.- Returns:
- true if a specific
PropertyValueConverter
is available.
-
getValueConverter
@Nullable public <DV,SV, PropertyValueConverter<DV,C extends PersistentProperty<C>, D extends ValueConversionContext<C>> SV, getValueConverterD> (C property) Description copied from interface:PropertyValueConversions
Get thePropertyValueConverter
for the given property.- Specified by:
getValueConverter
in interfacePropertyValueConversions
- Type Parameters:
DV
- domain-specific typeSV
- store-native typeC
- conversion context type- Parameters:
property
- must not be null.- Returns:
- the suitable
PropertyValueConverter
.
-
init
public void init()May be called just once to initialize the underlying factory with its values. -
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-