Enum Class NamingStrategy

java.lang.Object
java.lang.Enum<NamingStrategy>
tech.guilhermekaua.spigotboot.config.binding.NamingStrategy
All Implemented Interfaces:
Serializable, Comparable<NamingStrategy>, Constable

public enum NamingStrategy extends Enum<NamingStrategy>
Strategy for converting between Java field names and config keys.

Different strategies support different naming conventions commonly used in YAML configuration files.

  • Enum Constant Details

    • IDENTITY

      public static final NamingStrategy IDENTITY
      No conversion: fieldName → fieldName
    • SNAKE_CASE

      public static final NamingStrategy SNAKE_CASE
      Snake case: fieldName → field_name (DEFAULT)
    • KEBAB_CASE

      public static final NamingStrategy KEBAB_CASE
      Kebab case: fieldName → field-name
    • LOWER_CAMEL

      public static final NamingStrategy LOWER_CAMEL
      Lower camel: FieldName → fieldName
  • Method Details

    • values

      public static NamingStrategy[] 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 NamingStrategy 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
    • toConfig

      @NotNull public abstract @NotNull String toConfig(@NotNull @NotNull String javaName)
      Converts a Java field name to a config key.
      Parameters:
      javaName - the Java field name
      Returns:
      the config key
    • toJava

      @NotNull public abstract @NotNull String toJava(@NotNull @NotNull String configName)
      Converts a config key to a Java field name.
      Parameters:
      configName - the config key
      Returns:
      the Java field name