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 Details

    • convert

      <T> @Nullable T convert(Object source, Class<T> targetType)
      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 converted
      targetType - the target type
      Returns:
      the converted value
    • hasCustomWriteTarget

      boolean hasCustomWriteTarget(Class<?> sourceType)
      Returns whether we have a custom conversion registered to read sourceType 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 a Value returned by the driver and converts it into a simple type supported by Neo4j SDN. If the value cannot be converted, a TypeMismatchDataAccessException 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 an Object to a driver's value object.
      Parameters:
      value - the value to get written, may be null.
      sourceType - the type information describing the target type.
      conversionOverride - a conversion overriding the default
      Returns:
      a driver compatible value object.
    • isSimpleType

      boolean isSimpleType(Class<?> type)
      Return true if the given class represents a Neo4j simple type.
      Parameters:
      type - a type that should be checked whether it's simple or not
      Returns:
      true if type is a simple type, according to Neo4jSimpleTypes and the registered converters.