Module org.jooq
Package org.jooq

Interface EnumType

All Known Implementing Classes:
HistoryResolution, HistoryStatus

public interface EnumType
A SQL enum type. This can be any of the following:
  • In SQLDialect.MARIADB, this can be a column-scope enum type
  • In SQLDialect.MYSQL, this can be a column-scope enum type
  • In SQLDialect.POSTGRES, this can be a schema-scope enum type
  • In all other dialects, this can be an enum type as defined in the code generation configuration [#968]

Client code should not assume that the actual enum reference is a Java Enum. In Scala, for instance, enums are not idiomatic, and jOOQ implements them differently. In any case, this EnumType API is implemented by generated database enums.

Author:
Lukas Eder
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable Catalog
    The catalog of the enum type, if applicable.
    @NotNull String
    The literal as defined in the database
    @Nullable String
    The type name as registered in the database, if applicable (Postgres schema-scope enum type only).
    default @Nullable Schema
    The schema of the enum type, if applicable (Postgres schema-scope enum type only).
    static <E extends Enum<E> & EnumType>
    E
    lookupLiteral(Class<E> enumType, String literal)
    Look up an EnumType value by its getLiteral().
  • Method Details

    • getLiteral

      @NotNull @NotNull String getLiteral()
      The literal as defined in the database
    • getCatalog

      @Nullable default @Nullable Catalog getCatalog()
      The catalog of the enum type, if applicable. Otherwise, this returns null
    • getSchema

      @Nullable default @Nullable Schema getSchema()
      The schema of the enum type, if applicable (Postgres schema-scope enum type only). Otherwise, this returns null
    • getName

      @Nullable @Nullable String getName()
      The type name as registered in the database, if applicable (Postgres schema-scope enum type only). Otherwise, this returns null
    • lookupLiteral

      @Nullable static <E extends Enum<E> & EnumType> E lookupLiteral(Class<E> enumType, String literal)
      Look up an EnumType value by its getLiteral().

      This is similar to Enum.valueOf(Class, String), but uses getLiteral() (the database enum value) as a lookup key instead of Enum.name() (the generated Java value), and returns null if the literal wasn't found.