JHipster Domain Language (JDL) - Enums Permalink to " JHipster Domain Language (JDL) - Enums"

Summary Permalink to "Summary"

  1. Syntax
  2. Examples
    1. Basic example
    2. With values
    3. Commenting

Syntax Permalink to "Syntax"

Enumeration declaration is done as follows:

enum <enum name> {
  <ENUM KEY> [(<enum value>)]
}
  • Enumeration entry values are mandatory
    • And uppercase keys must be used
  • Enumeration entry values are optional, and must be wrapped inside parenthesises

Examples Permalink to "Examples"

Basic example Permalink to "Basic example"

enum Country {
  BELGIUM,
  FRANCE,
  ITALY
}

And its use:

enum Country {}

entity A {
  country Country
}

With values Permalink to "With values"

Starting from JHipster Core v6, enum values can have explicit values:

enum Country {
  BELGIUM (Belgium),
  FRANCE (France),
  ITALY (Italy),
  CHINA ("中国")
}

Commenting Permalink to "Commenting"

Just like relationships, entities and fields, commenting is possible for enums, with the same rules.

Comments will later be added as Javadoc comments by JHipster. The JDL possesses its own kind of comment:

  • // an ignored comment
  • /** not an ignored comment */

Therefore, anything that starts with // is considered an internal comment for JDL, and will not be counted as Javadoc. Please note that the JDL Studio directives that start with # will be ignored during parsing.

/** This comment will be taken into account */
enum Country {
  // But not this one!
  FRANCE
}