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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid<DV,SV, C extends PersistentProperty<C>, D extends ValueConversionContext<C>>
PropertyValueConverter<DV,SV, D> getValueConverter(C property) Get thePropertyValueConverterfor the given property.Get theValueConverterRegistryused for path configured converters.booleanhasValueConverter(PersistentProperty<?> property) Check if aPropertyValueConverteris present for the given property.voidinit()May be called just once to initialize the underlying factory with its values.voidsetConverterCacheEnabled(boolean converterCacheEnabled) Dis-/Enable caching.voidsetConverterFactory(PropertyValueConverterFactory converterFactory) voidsetValueConverterRegistry(ValueConverterRegistry<?> valueConverterRegistry) Set theconverter registryfor path configured converters.
-
Constructor Details
-
SimplePropertyValueConversions
public SimplePropertyValueConversions()
-
-
Method Details
-
setConverterFactory
- Parameters:
converterFactory- must not be null.
-
getConverterFactory
-
setValueConverterRegistry
Set theconverter registryfor path configured converters. This is short for adding aPropertyValueConverterFactories.ConfiguredInstanceServingValueConverterFactoryat the end of aPropertyValueConverterFactories.ChainedPropertyValueConverterFactory.- Parameters:
valueConverterRegistry- must not be null.
-
getValueConverterRegistry
Get theValueConverterRegistryused 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 ofconverterinstances.
-
hasValueConverter
Description copied from interface:PropertyValueConversionsCheck if aPropertyValueConverteris present for the given property.- Specified by:
hasValueConverterin interfacePropertyValueConversions- Parameters:
property- must not be null.- Returns:
- true if a specific
PropertyValueConverteris available.
-
getValueConverter
@Nullable public <DV,SV, PropertyValueConverter<DV,C extends PersistentProperty<C>, D extends ValueConversionContext<C>> SV, getValueConverterD> (C property) Description copied from interface:PropertyValueConversionsGet thePropertyValueConverterfor the given property.- Specified by:
getValueConverterin 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:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-