Class EnumMapper<E extends Enum<E>>

java.lang.Object
org.jdbi.v3.core.mapper.EnumMapper<E>
Type Parameters:
E - the enum type mapped
All Implemented Interfaces:
ColumnMapper<E>

public abstract class EnumMapper<E extends Enum<E>> extends Object implements ColumnMapper<E>
Column mapper for Java enum types.
See Also:
  • Method Details

    • byName

      public static <E extends Enum<E>> ColumnMapper<E> byName(Class<E> type)
      Map database string values to enum names.
      Type Parameters:
      E - the enum type to map
      Parameters:
      type - the enum type to map
      Returns:
      an enum mapper that matches on Enum.name()
    • byOrdinal

      public static <E extends Enum<E>> ColumnMapper<E> byOrdinal(Class<E> type)
      Map database integer values to enum ordinal values.
      Type Parameters:
      E - the enum type to map
      Parameters:
      type - the enum type to map
      Returns:
      an enum mapper that matches on Enum.ordinal()