Package org.springframework.data.convert
Class PropertyValueConversionService
java.lang.Object
org.springframework.data.convert.PropertyValueConversionService
Conversion service based on
CustomConversions
used to convert domain and store values using
property-specific converters
.- Since:
- 2.7
- Author:
- Mark Paluch
- See Also:
-
Constructor Summary
ConstructorDescriptionPropertyValueConversionService
(CustomConversions conversions) Constructs a new instance of thePropertyValueConversionService
initialized with the given, requiredCustomConversions
for resolving thePropertyValueConversions
used to convertPersistentProperty
values during data access operations. -
Method Summary
Modifier and TypeMethodDescriptionboolean
hasConverter
(PersistentProperty<?> property) Return true if aPropertyValueConverter
is registered for thePersistentProperty
.<P extends PersistentProperty<P>,
VCC extends ValueConversionContext<P>>
ObjectConvert a value from its store-native representation into its domain-specific type.<P extends PersistentProperty<P>,
VCC extends ValueConversionContext<P>>
ObjectConvert a value from its domain-specific value into its store-native representation.
-
Constructor Details
-
PropertyValueConversionService
Constructs a new instance of thePropertyValueConversionService
initialized with the given, requiredCustomConversions
for resolving thePropertyValueConversions
used to convertPersistentProperty
values during data access operations.- Parameters:
conversions
-CustomConversions
used to handle domain and store type conversions; must not be null.- Throws:
IllegalArgumentException
- ifCustomConversions
is null.- See Also:
-
-
Method Details
-
hasConverter
Return true if aPropertyValueConverter
is registered for thePersistentProperty
.If this method returns true, it means
read(Object, PersistentProperty, ValueConversionContext)
andwrite(Object, PersistentProperty, ValueConversionContext)
are capable of handling conversions.- Parameters:
property
-property
to evaluate for registration.- Returns:
- true if a
PropertyValueConverter
is registered for thePersistentProperty
. - See Also:
-
read
@Nullable public <P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>> Object read(@Nullable Object value, P property, VCC context) Convert a value from its store-native representation into its domain-specific type.- Type Parameters:
P
- property type.VCC
- value conversion context type.- Parameters:
value
- the value to convert. Can benull
.property
- the underlying property.context
- the context object.- Returns:
- the value to be used in the domain model. Can be
null
.
-
write
@Nullable public <P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>> Object write(@Nullable Object value, P property, VCC context) Convert a value from its domain-specific value into its store-native representation.- Type Parameters:
P
- property type.VCC
- value conversion context type.- Parameters:
value
- the value to convert. Can benull
.property
- the underlying property.context
- the context object.- Returns:
- the value to be written to the data store. Can be
null
.
-