Class EnumConverter<E extends Enum<E>>

java.lang.Object
org.fastnate.generator.converter.EnumConverter<E>
Type Parameters:
E - the type of the enum
All Implemented Interfaces:
ValueConverter<E>

public class EnumConverter<E extends Enum<E>> extends Object implements ValueConverter<E>
Describes a enum property of an EntityClass.
Author:
Tobias Liefke
  • Field Details

    • targetType

      private final Class<E extends Enum<E>> targetType
    • exportType

      private final jakarta.persistence.EnumType exportType
  • Constructor Details

    • EnumConverter

      public EnumConverter(AttributeAccessor attribute, Class<E> targetType, boolean mapKey)
      Creates a new instance of this EnumConverter.
      Parameters:
      attribute - the inspected attribute
      targetType - the type of the enum
      mapKey - indicates that the converter is for the key of a map
  • Method Details

    • getExpression

      public ColumnExpression getExpression(E value, GeneratorContext context)
      Description copied from interface: ValueConverter
      Builds the expression for writing the given value into an SQL clause.
      Specified by:
      getExpression in interface ValueConverter<E extends Enum<E>>
      Parameters:
      value - the current value
      context - the current context (contains the database dialect).
      Returns:
      the expression (that is including surrounding ' for string literals)
    • getExpression

      public ColumnExpression getExpression(String defaultValue, GeneratorContext context)
      Description copied from interface: ValueConverter
      Builds the expression for writing the default value into an SQL clause.
      Specified by:
      getExpression in interface ValueConverter<E extends Enum<E>>
      Parameters:
      defaultValue - the default value, as given in an DefaultValue expression
      context - the current context (contains the database dialect).
      Returns:
      the expression (that is including surrounding ' for string literals)