Enum Class NamingType

java.lang.Object
java.lang.Enum<NamingType>
org.seasar.doma.jdbc.entity.NamingType
All Implemented Interfaces:
Serializable, Comparable<NamingType>, Constable

public enum NamingType extends Enum<NamingType>
Defines naming conventions for converting between entity/property names and table/column names.

This enum provides strategies for automatically deriving database table names from entity class names when Table.name() is not specified, and for deriving database column names from entity property names when Column.name() is not specified.

Naming conventions are essential for maintaining consistent naming patterns between Java code and database schemas, especially in applications that follow specific naming standards.

See Also:
  • Enum Constant Details

    • NONE

      public static final NamingType NONE
      Preserves the original name without any conversion.

      This naming convention leaves entity and property names unchanged when mapping to table and column names. Use this when your Java naming conventions already match your database naming conventions.

    • SNAKE_UPPER_CASE

      public static final NamingType SNAKE_UPPER_CASE
      Converts camel case text to snake case with uppercase letters.

      This naming convention transforms Java camelCase identifiers to database-style SNAKE_CASE identifiers with all uppercase letters. This is commonly used in databases that follow uppercase naming conventions.

      Examples:

      • aaaBbb is converted to AAA_BBB
      • aaa3Bbb is converted to AAA3_BBB
      See Also:
    • SNAKE_LOWER_CASE

      public static final NamingType SNAKE_LOWER_CASE
      Converts camel case text to snake case with lowercase letters.

      This naming convention transforms Java camelCase identifiers to database-style snake_case identifiers with all lowercase letters. This is commonly used in databases that follow lowercase naming conventions.

      Examples:

      • aaaBbb is converted to aaa_bbb
      • aaa3Bbb is converted to aaa3_bbb
      See Also:
    • UPPER_CASE

      public static final NamingType UPPER_CASE
      Converts camel case text to all uppercase text without adding underscores.

      This naming convention transforms Java camelCase identifiers to database-style identifiers with all uppercase letters, but without adding underscores between words.

      Example:

      • aaaBbb is converted to AAABBB
      See Also:
    • LOWER_CASE

      public static final NamingType LOWER_CASE
      Converts camel case text to all lowercase text without adding underscores.

      This naming convention transforms Java camelCase identifiers to database-style identifiers with all lowercase letters, but without adding underscores between words.

      Example:

      • aaaBbb is converted to aaabbb
      See Also:
  • Method Details

    • values

      public static NamingType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NamingType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • apply

      public abstract String apply(String text)
      Applies this naming convention to convert a Java identifier to a database identifier.

      This method is used to convert entity class names to table names and entity property names to column names according to the specific naming convention.

      Parameters:
      text - the entity name or property name to convert
      Returns:
      the converted table name or column name
      Throws:
      DomaNullPointerException - if the text is null
    • revert

      public abstract String revert(String text)
      Attempts to convert a database identifier back to its original Java identifier form.

      This method performs the reverse operation of apply(String), converting database table and column names back to their corresponding Java entity and property names. The conversion may not be perfect for all naming conventions.

      Parameters:
      text - the database table or column name to convert back
      Returns:
      the Java entity or property name
      Throws:
      DomaNullPointerException - if the text is null