Package org.springframework.data.convert
Class PropertyValueConverterRegistrar<P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.convert.PropertyValueConverterRegistrar<P>
Configuration class used to register a
PropertyValueConverter
with
a SimplePropertyValueConverterRegistry
that can be used in 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>> Helper class used 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 class used to build up a fluent registration API starting with writing. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionObtain theSimplePropertyValueConverterRegistry
.registerConverter
(Class<?> type, String path, PropertyValueConverter<?, ?, ? extends ValueConversionContext<?>> converter) Register the givenconverter
for the given type and property identified by 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
- aFunction
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
- aFunction
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 givenconverter
for the given type and property identified by its name.- Parameters:
type
- the domain type to obtain the property frompath
- the property name.converter
- theconverter
to apply.- Returns:
- this.
-
registerConvertersIn
Register collectedconverters
within the givenregistry
.- Parameters:
target
-ValueConverterRegistry
from which to registerconverters
; must not be null.- Throws:
IllegalArgumentException
- if theValueConverterRegistry
is null.- See Also:
-
buildRegistry
Obtain theSimplePropertyValueConverterRegistry
.- Returns:
- new instance of
SimplePropertyValueConverterRegistry
.
-