Package org.springframework.data.convert
Interface PropertyValueConverter<DV,SV,C extends ValueConversionContext<? extends PersistentProperty<?>>>
- Type Parameters:
DV
- domain-specific type.SV
- store-native type.C
- the store specificconversion context
.
- All Known Implementing Classes:
PropertyValueConverter.FunctionPropertyValueConverter
,PropertyValueConverter.ObjectToObjectPropertyValueConverter
public interface PropertyValueConverter<DV,SV,C extends ValueConversionContext<? extends PersistentProperty<?>>>
PropertyValueConverter
provides a symmetric way of converting certain properties from domain to
store-specific values.
A PropertyValueConverter
is, other than a ReadingConverter
or WritingConverter
, only applied
to special annotated fields which allows a fine-grained conversion of certain values within a specific context.
Converter methods are called with non-null values only and provide specific hooks for null
value handling.
readNull(ValueConversionContext)
and writeNull(ValueConversionContext)
methods are specifically
designated to either retain null
values or return a different value to indicate null
values.
- Since:
- 2.7
- Author:
- Christoph Strobl, Mark Paluch
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
APropertyValueConverter
that delegates conversion to the givenBiFunction
s.static enum
No-opPropertyValueConverter
implementation. -
Method Summary
Modifier and TypeMethodDescription@Nullable DV
Convert the given store specific value into it's domain value representation.default @Nullable DV
Convert the givennull
value from the store into its domain value representation.@Nullable SV
Convert the given domain-specific value into it's native store representation.default @Nullable SV
Convert the givennull
value from the domain model into it's native store representation.
-
Method Details
-
read
Convert the given store specific value into it's domain value representation. Typically, a read operation.- Parameters:
value
- value to read.context
-ValueConversionContext
containing store-specific metadata used in the value conversion; never null.- Returns:
- the converted value. Can be null.
-
readNull
Convert the givennull
value from the store into its domain value representation. Typically, a read operation. Returnsnull
by default.- Parameters:
context
-ValueConversionContext
containing store-specific metadata used in the value conversion; never null.- Returns:
- the converted value. Can be null.
-
write
Convert the given domain-specific value into it's native store representation. Typically, a write operation.- Parameters:
value
- value to write; can be null.context
-ValueConversionContext
containing store-specific metadata used in the value conversion; never null.- Returns:
- the converted value. Can be null.
-
writeNull
Convert the givennull
value from the domain model into it's native store representation. Typically, a write operation. Returnsnull
by default.- Parameters:
context
-ValueConversionContext
containing store-specific metadata used in the value conversion; never null.- Returns:
- the converted value. Can be null.
-