Class ConverterResolver

java.lang.Object
cz.cvut.kbss.jopa.model.metamodel.ConverterResolver

public class ConverterResolver extends Object
Determines potential converters which may be used on a field.

Currently, only built-in converters for data and annotation property attributes are supported, but in the future, custom converters should be also supported.

  • Method Details

    • createCustomConverter

      public static ConverterWrapper<?,?> createCustomConverter(Class<?> converterType)
    • resolveConverterAttributeType

      public static Class<?> resolveConverterAttributeType(Class<?> converterType)
    • resolveConverter

      public Optional<ConverterWrapper<?,?>> resolveConverter(Type<?> type)
      Alternative method for resolving converter. Can be used when the persistent attribute type is not relevant and/or the class PropertyAttributes is not used for attribute configuration, e.g. for attributes defined by a query.

      Determines converter which should be used for transformation of values to and from the specified type of field.

      Beside custom converters, the system supports a number of built-in converters, which ensure that e.g. widening conversion or mapping to Java 8 Date/Time API is supported.

      Parameters:
      type - attribute type as defined in Type (not to be confused with Type)
      Returns:
      Possible converter instance to be used for transformation of values of the specified field. Returns empty Optional if no suitable converter is found (or needed)
      See Also:
    • registerConverter

      public void registerConverter(Class<?> attributeType, ConverterWrapper<?,?> converter)
      Registers the specified converter for automatically converting values to the specified attribute type.
      Parameters:
      attributeType - Entity attribute type to convert to/from
      converter - Converter instance