org.springframework.data.relational.core.conversion

## Class BasicRelationalConverter

- java.lang.Object
- - org.springframework.data.relational.core.conversion.BasicRelationalConverter

All Implemented Interfaces:
  RelationalConverter

    public class BasicRelationalConverter
    extends Object
    implements RelationalConverter

`RelationalConverter` that uses a `MappingContext` to apply basic conversion of relational values to property values.

Conversion is configurable by providing a customized `CustomConversions`.

Author:
  Mark Paluch, Jens Schauder
See Also:
  `MappingContext`, `SimpleTypeHolder`, `CustomConversions`

### Constructor Summary

Constructors
Constructor and Description
`BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context)` Creates a new `BasicRelationalConverter` given `MappingContext`.
`BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context, CustomConversions conversions)` Creates a new `BasicRelationalConverter` given `MappingContext` and `CustomConversions`.

### Method Summary

All Methods Instance Methods Concrete Methods
`<T> T` `createInstance(PersistentEntity<T,RelationalPersistentProperty> entity, Function<PreferredConstructor.Parameter<?,RelationalPersistentProperty>,Object> parameterValueProvider)` Create a new instance of `PersistentEntity` given `ParameterValueProvider` to obtain constructor properties.
`CustomConversions` `getConversions()`
`ConversionService` `getConversionService()` Returns the underlying `ConversionService` used by the converter.
`MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty>` `getMappingContext()` Returns the underlying `MappingContext` used by the converter.
`<T> PersistentPropertyAccessor<T>` `getPropertyAccessor(PersistentEntity<T,?> persistentEntity, T instance)` Return a `PersistentPropertyAccessor` to access property values of the `instance`.
`Object` `readValue(Object value, TypeInformation<?> type)` Read a relational value into the desired `destination type`.
`Object` `writeValue(Object value, TypeInformation<?> type)` Write a property value into a relational type that can be stored natively.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BasicRelationalConverter

    public BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context)

Creates a new `BasicRelationalConverter` given `MappingContext`.

Parameters:
  `context` - must not be null. org.springframework.data.jdbc.core.DefaultDataAccessStrategyUnitTests

#### BasicRelationalConverter

    public BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context,
                                    CustomConversions conversions)

Creates a new `BasicRelationalConverter` given `MappingContext` and `CustomConversions`.

Parameters:
  `context` - must not be null.
  `conversions` - must not be null.

### Method Detail

#### getConversionService

    public ConversionService getConversionService()

Description copied from interface: `RelationalConverter`
Returns the underlying `ConversionService` used by the converter.

Specified by:
  `getConversionService` in interface `RelationalConverter`
Returns:
  never null.

#### getConversions

    public CustomConversions getConversions()

#### getMappingContext

    public MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> getMappingContext()

Description copied from interface: `RelationalConverter`
Returns the underlying `MappingContext` used by the converter.

Specified by:
  `getMappingContext` in interface `RelationalConverter`
Returns:
  never null

#### getPropertyAccessor

    public <T> PersistentPropertyAccessor<T> getPropertyAccessor(PersistentEntity<T,?> persistentEntity,
                                                                 T instance)

Description copied from interface: `RelationalConverter`
Return a `PersistentPropertyAccessor` to access property values of the `instance`.

Specified by:
  `getPropertyAccessor` in interface `RelationalConverter`
Parameters:
  `persistentEntity` - the kind of entity to operate on. Must not be `null`.
  `instance` - the instance to operate on. Must not be `null`.
Returns:
  guaranteed to be not `null`.

#### createInstance

    public <T> T createInstance(PersistentEntity<T,RelationalPersistentProperty> entity,
                                Function<PreferredConstructor.Parameter<?,RelationalPersistentProperty>,Object> parameterValueProvider)

Description copied from interface: `RelationalConverter`
Create a new instance of `PersistentEntity` given `ParameterValueProvider` to obtain constructor properties.

Specified by:
  `createInstance` in interface `RelationalConverter`
Type Parameters:
  `T` - the type of entity to create.
Parameters:
  `entity` - the kind of entity to create. Must not be `null`.
  `parameterValueProvider` - a function that provides the value to pass to a constructor, given a `PreferredConstructor.Parameter`. Must not be `null`.
Returns:
  the instantiated entity. Guaranteed to be not `null`.

#### readValue

    @Nullable
    public Object readValue(@Nullable
                                      Object value,
                                      TypeInformation<?> type)

Description copied from interface: `RelationalConverter`
Read a relational value into the desired `destination type`.

Specified by:
  `readValue` in interface `RelationalConverter`
Parameters:
  `value` - a value as it is returned by the driver accessing the persistence store. May be `null`.
  `type` - `TypeInformation` into which the value is to be converted. Must not be `null`.
Returns:
  The converted value. May be `null`.

#### writeValue

    @Nullable
    public Object writeValue(@Nullable
                                       Object value,
                                       TypeInformation<?> type)

Description copied from interface: `RelationalConverter`
Write a property value into a relational type that can be stored natively.

Specified by:
  `writeValue` in interface `RelationalConverter`
Parameters:
  `value` - a value as it is used in the object model. May be `null`.
  `type` - `TypeInformation` into which the value is to be converted. Must not be `null`.
Returns:
  The converted value. May be `null`.