@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface EnumType
EnumType is optional since EnumTranslator
is the default translator to use for
an Enum field when no annotation is specified.
Use EnumType
to provide an alternate translator with
translator()
or to define a default Enum to use when the column name read is
not a valid Enum as determined by Class.getEnumConstants()
.
Example:
public class SomeRowClass { @EnumType(defaultEnumName="Bad") SomeEnum e; ... } public enum SomeEnum { Good, Bad, Ugly; }
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
defaultEnumName
The name of the Enum (
Enum.name() ) for the default Enum. |
java.lang.Class<? extends EnumTranslator> |
translator
Type translator to use to convert Enum types to/from column.
|
public abstract java.lang.Class<? extends EnumTranslator> translator
public abstract java.lang.String defaultEnumName
Enum.name()
) for the default Enum. The name
supplied here determines the Enum to return from
EnumTranslator.read(java.sql.ResultSet, int)
when database column
does not match any Enum names. Name is case sensitive.