Interface Neo4jConversionService
@API(status=STABLE,
since="6.0")
public interface Neo4jConversionService
This service orchestrates a standard Spring conversion service with
Neo4jConversions
registered.
It provides simple delegating functions that allow for an override of the converter being used.- Since:
- 6.0
- Author:
- Michael J. Simons
-
Method Summary
Modifier and TypeMethodDescription<T> T
Delegates to the underlying service, without the possibility to run a custom conversion.boolean
hasCustomWriteTarget
(Class<?> sourceType) Returns whether we have a custom conversion registered to readsourceType
into a native type.boolean
isSimpleType
(Class<?> type) readValue
(org.neo4j.driver.Value source, TypeInformation<?> targetType, Neo4jPersistentPropertyConverter<?> conversionOverride) Reads aValue
returned by the driver and converts it into asimple type
supported by Neo4j SDN.org.neo4j.driver.Value
writeValue
(Object value, TypeInformation<?> sourceType, Neo4jPersistentPropertyConverter<?> conversionOverride) Converts anObject
to a driver's value object.
-
Method Details
-
convert
Delegates to the underlying service, without the possibility to run a custom conversion.- Type Parameters:
T
- The type to be returned- Parameters:
source
- The source to be convertedtargetType
- The target type- Returns:
- The converted value
-
hasCustomWriteTarget
Returns whether we have a custom conversion registered to readsourceType
into a native type. The returned type might be a subclass of the given expected type though.- Parameters:
sourceType
- must not be null- Returns:
- True if a custom write target exists.
- See Also:
-
readValue
@Nullable Object readValue(@Nullable org.neo4j.driver.Value source, TypeInformation<?> targetType, @Nullable Neo4jPersistentPropertyConverter<?> conversionOverride) Reads aValue
returned by the driver and converts it into asimple type
supported by Neo4j SDN. If the value cannot be converted, aTypeMismatchDataAccessException
will be thrown, it's cause indicating the failed conversion.The returned object is generic as this method will take create target collections in case the incoming value describes a collection.
- Parameters:
source
- The value to be read, may be null.targetType
- The type information describing the target type.conversionOverride
- An optional conversion override.- Returns:
- A simple type or null, if the value was null or
Values.NULL
. - Throws:
TypeMismatchDataAccessException
- In case the value cannot be converted to the target type
-
writeValue
org.neo4j.driver.Value writeValue(@Nullable Object value, TypeInformation<?> sourceType, @Nullable Neo4jPersistentPropertyConverter<?> conversionOverride) Converts anObject
to a driver's value object.- Parameters:
value
- The value to get written, may be null.sourceType
- The type information describing the target type.- Returns:
- A driver compatible value object.
-
isSimpleType
- Parameters:
type
- A type that should be checked whether it's simple or not.- Returns:
- True if
type
is a simple type, according toNeo4jSimpleTypes
and the registered converters.
-