Package org.springframework.data.convert
Class PropertyValueConverterRegistrar<P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.convert.PropertyValueConverterRegistrar<P>
Configuration class to register a
PropertyValueConverter
with a SimplePropertyValueConverterRegistry
that can be used with PropertyValueConversions
.
It is possible to register type safe converters via registerConverter(Class, Function)
registrar.registerConverter(Person.class, Person::getName) // .writing(StringConverter::encrypt) // .reading(StringConverter::decrypt);
- Since:
- 2.7
- Author:
- Christoph Strobl, Oliver Drotbohm
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PropertyValueConverterRegistrar.ReadingConverterRegistrationBuilder<T,
S, R, P extends PersistentProperty<P>> A helper to build a fluent API to register how to read a database value into a domain object property.static class
PropertyValueConverterRegistrar.WritingConverterRegistrationBuilder<T,
S, P extends PersistentProperty<P>> Helper to build up a fluent registration API starting on -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionObtain theSimplePropertyValueConverterRegistry
.registerConverter
(Class<?> type, String path, PropertyValueConverter<?, ?, ? extends ValueConversionContext<?>> converter) Register the given converter for the types property identified via its name.registerConverter
(Class<T> type, String propertyName, Class<S> propertyType) Starts a converter registration by pointing to a property of a domain type.registerConverter
(Class<T> type, Function<T, S> property) Starts a converter registration by pointing to a property of a domain type.void
registerConvertersIn
(ValueConverterRegistry<P> target) Register collectedconverters
within the givenregistry
.
-
Constructor Details
-
PropertyValueConverterRegistrar
public PropertyValueConverterRegistrar()
-
-
Method Details
-
registerConverter
public <T,S> PropertyValueConverterRegistrar.WritingConverterRegistrationBuilder<T,S, registerConverterP> (Class<T> type, Function<T, S> property) Starts a converter registration by pointing to a property of a domain type.- Type Parameters:
T
- the domain typeS
- the property type- Parameters:
type
- the domain type to obtain the property fromproperty
- a function to describe the property to be referenced. Usually a method handle to a getter.- Returns:
- will never be null.
-
registerConverter
public <T,S> PropertyValueConverterRegistrar.WritingConverterRegistrationBuilder<T,S, registerConverterP> (Class<T> type, String propertyName, Class<S> propertyType) Starts a converter registration by pointing to a property of a domain type.- Type Parameters:
T
- the domain typeS
- the property type- Parameters:
type
- the domain type to obtain the property frompropertyName
- a function to describe the property to be referenced. Usually a method handle to a getter.- Returns:
- will never be null.
-
registerConverter
public PropertyValueConverterRegistrar<P> registerConverter(Class<?> type, String path, PropertyValueConverter<?, ?, ? extends ValueConversionContext<?>> converter) Register the given converter for the types property identified via its name.- Parameters:
type
- the domain type to obtain the property frompath
- the property name.converter
- the converter to apply.- Returns:
- this.
-
buildRegistry
Obtain theSimplePropertyValueConverterRegistry
.- Returns:
- new instance of
SimplePropertyValueConverterRegistry
.
-
registerConvertersIn
Register collectedconverters
within the givenregistry
.
-