Interface PropertyValueConverter<DV,SV,C extends ValueConversionContext<? extends PersistentProperty<?>>>

Type Parameters:
DV - domain-specific type.
SV - store-native type.
C - the store specific conversion 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:
  • Method Details

    • read

      @Nullable DV read(SV value, C context)
      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

      @Nullable default DV readNull(C context)
      Convert the given null value from the store into its domain value representation. Typically, a read operation. Returns null by default.
      Parameters:
      context - ValueConversionContext containing store-specific metadata used in the value conversion; never null.
      Returns:
      the converted value. Can be null.
    • write

      @Nullable SV write(DV value, C context)
      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

      @Nullable default SV writeNull(C context)
      Convert the given null value from the domain model into it's native store representation. Typically, a write operation. Returns null by default.
      Parameters:
      context - ValueConversionContext containing store-specific metadata used in the value conversion; never null.
      Returns:
      the converted value. Can be null.