Package org.springframework.data.convert
Class SimplePropertyValueConversions
java.lang.Object
org.springframework.data.convert.SimplePropertyValueConversions
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
,PropertyValueConversions
public class SimplePropertyValueConversions
extends Object
implements PropertyValueConversions, org.springframework.beans.factory.InitializingBean
PropertyValueConversions
implementation allowing a PropertyValueConverterFactory
creating
converters
to be chosen. Activating cahing
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:
-
PropertyValueConversions
InitializingBean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Initializes thisSimplePropertyValueConversions
instance.Returns the configuredPropertyValueConverterFactory
responsible for creating the actualPropertyValueConverter
.<DV,
SV, P extends PersistentProperty<P>, D extends ValueConversionContext<P>>
PropertyValueConverter<DV,SV, D> getValueConverter
(P property) Get theValueConverterRegistry
used for path configured converters.boolean
hasValueConverter
(PersistentProperty<?> property) Determines whether aPropertyValueConverter
has been registered for the givenproperty
.void
init()
May be called just once to initialize the underlying factory with its values.void
setConverterCacheEnabled
(boolean converterCacheEnabled) Configure whether to use converter the cache.void
setConverterFactory
(PropertyValueConverterFactory converterFactory) Set thePropertyValueConverterFactory
responsible for creating the actualPropertyValueConverter
.void
setValueConverterRegistry
(ValueConverterRegistry<?> valueConverterRegistry) Set theconverter registry
used for path configured converters.
-
Constructor Details
-
SimplePropertyValueConversions
public SimplePropertyValueConversions()
-
-
Method Details
-
setConverterFactory
Set thePropertyValueConverterFactory
responsible for creating the actualPropertyValueConverter
.- Parameters:
converterFactory
-PropertyValueConverterFactory
used to create the actualPropertyValueConverter
.- See Also:
-
getConverterFactory
Returns the configuredPropertyValueConverterFactory
responsible for creating the actualPropertyValueConverter
.- Returns:
- the configured
PropertyValueConverterFactory
; can be null. - See Also:
-
setValueConverterRegistry
Set theconverter registry
used for path configured converters.This is short for adding a
PropertyValueConverterFactories.ConfiguredInstanceServingValueConverterFactory
at the end of aPropertyValueConverterFactories.ChainedPropertyValueConverterFactory
.- Parameters:
valueConverterRegistry
- registry ofPropertyValueConverters
.- See Also:
-
getValueConverterRegistry
Get theValueConverterRegistry
used 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 ofconverter
instances.
-
hasValueConverter
Determines whether aPropertyValueConverter
has been registered for the givenproperty
.- Specified by:
hasValueConverter
in interfacePropertyValueConversions
- Parameters:
property
-PersistentProperty
to evaluate.- Returns:
- true if a
PropertyValueConverter
has been registered for the givenproperty
. - See Also:
-
getValueConverter
@NonNull public <DV,SV, PropertyValueConverter<DV,P extends PersistentProperty<P>, D extends ValueConversionContext<P>> SV, getValueConverterD> (P property) Description copied from interface:PropertyValueConversions
- Specified by:
getValueConverter
in interfacePropertyValueConversions
- Type Parameters:
DV
- domain-specific typeSV
- store-native typeP
- conversion context type- Parameters:
property
-PersistentProperty
used to look up the registeredPropertyValueConverter
; must not be null.- Returns:
- the
PropertyValueConverter
registered 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 thisSimplePropertyValueConversions
instance.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- See Also:
-