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 allowing a PropertyValueConverterFactory creating
converters to be chosen. Activating caching
allows converters to be reused.
Providing a SimplePropertyValueConverterRegistry adds path configured converter instances.
This class should be initialized. If not, init() will be called on the first
attempt of converter retrieval.
- Since:
- 2.7
- Author:
- Christoph Strobl, Mark Paluch
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInitializes thisSimplePropertyValueConversionsinstance.@Nullable PropertyValueConverterFactoryReturns the configuredPropertyValueConverterFactoryresponsible for creating the actualPropertyValueConverter.<DV,SV, P extends PersistentProperty<P>, D extends ValueConversionContext<P>>
PropertyValueConverter<DV,SV, D> getValueConverter(P property) @Nullable ValueConverterRegistry<?>Get theValueConverterRegistryused for path configured converters.booleanhasValueConverter(PersistentProperty<?> property) Determines whether aPropertyValueConverterhas been registered for the givenproperty.voidinit()May be called just once to initialize the underlying factory with its values.voidsetConverterCacheEnabled(boolean converterCacheEnabled) Configure whether to use converter the cache.voidsetConverterFactory(@Nullable PropertyValueConverterFactory converterFactory) Set thePropertyValueConverterFactoryresponsible for creating the actualPropertyValueConverter.voidsetValueConverterRegistry(@Nullable ValueConverterRegistry<?> valueConverterRegistry) Set theconverter registryused for path configured converters.
-
Constructor Details
-
SimplePropertyValueConversions
public SimplePropertyValueConversions()
-
-
Method Details
-
setConverterFactory
Set thePropertyValueConverterFactoryresponsible for creating the actualPropertyValueConverter.- Parameters:
converterFactory-PropertyValueConverterFactoryused to create the actualPropertyValueConverter.- See Also:
-
getConverterFactory
Returns the configuredPropertyValueConverterFactoryresponsible for creating the actualPropertyValueConverter.- Returns:
- the configured
PropertyValueConverterFactory; can be null. - See Also:
-
setValueConverterRegistry
Set theconverter registryused for path configured converters.This is short for adding a
PropertyValueConverterFactories.ConfiguredInstanceServingValueConverterFactoryat the end of aPropertyValueConverterFactories.ChainedPropertyValueConverterFactory.- Parameters:
valueConverterRegistry- registry ofPropertyValueConverters.- See Also:
-
getValueConverterRegistry
Get theValueConverterRegistryused for path configured converters.- Returns:
- the configured
ValueConverterRegistry; can be null. - See Also:
-
setConverterCacheEnabled
public void setConverterCacheEnabled(boolean converterCacheEnabled) Configure whether to use converter the cache. Enabled by default.- Parameters:
converterCacheEnabled- set to true to enable caching ofconverterinstances.
-
hasValueConverter
Determines whether aPropertyValueConverterhas been registered for the givenproperty.- Specified by:
hasValueConverterin interfacePropertyValueConversions- Parameters:
property-PersistentPropertyto evaluate.- Returns:
- true if a
PropertyValueConverterhas been registered for the givenproperty. - See Also:
-
getValueConverter
public <DV,SV, PropertyValueConverter<DV,P extends PersistentProperty<P>, D extends ValueConversionContext<P>> SV, getValueConverterD> (P property) Description copied from interface:PropertyValueConversions- Specified by:
getValueConverterin interfacePropertyValueConversions- Type Parameters:
DV- domain-specific typeSV- store-native typeP- conversion context type- Parameters:
property-PersistentPropertyused to look up the registeredPropertyValueConverter; must not be null.- Returns:
- the
PropertyValueConverterregistered for the givenPersistentProperty; never null. - See Also:
-
init
public void init()May be called just once to initialize the underlying factory with its values. -
afterPropertiesSet
public void afterPropertiesSet()Initializes thisSimplePropertyValueConversionsinstance.- Specified by:
afterPropertiesSetin interfaceInitializingBean- See Also:
-