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
ConstructorsConstructorDescriptionPropertyValueConversionService(CustomConversions conversions) Constructs a new instance of thePropertyValueConversionServiceinitialized with the given, requiredCustomConversionsfor resolving thePropertyValueConversionsused to convertPersistentPropertyvalues during data access operations. -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasConverter(PersistentProperty<?> property) Return true if aPropertyValueConverteris registered for thePersistentProperty.<P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>>
@Nullable ObjectConvert a value from its store-native representation into its domain-specific type.<P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>>
@Nullable ObjectConvert a value from its domain-specific value into its store-native representation.
-
Constructor Details
-
PropertyValueConversionService
Constructs a new instance of thePropertyValueConversionServiceinitialized with the given, requiredCustomConversionsfor resolving thePropertyValueConversionsused to convertPersistentPropertyvalues during data access operations.- Parameters:
conversions-CustomConversionsused to handle domain and store type conversions; must not be null.- Throws:
IllegalArgumentException- ifCustomConversionsis null.- See Also:
-
-
Method Details
-
hasConverter
Return true if aPropertyValueConverteris 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-propertyto evaluate for registration.- Returns:
- true if a
PropertyValueConverteris registered for thePersistentProperty. - See Also:
-
read
public <P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>> @Nullable 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
public <P extends PersistentProperty<P>,VCC extends ValueConversionContext<P>> @Nullable 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.
-