Enum Class NamingCase

java.lang.Object
java.lang.Enum<NamingCase>
cloud.opencode.base.string.naming.NamingCase
All Implemented Interfaces:
Serializable, Comparable<NamingCase>, Constable

public enum NamingCase extends Enum<NamingCase>
Naming Convention Enumeration 命名风格枚举

Defines various naming conventions for string conversion.

定义字符串转换的各种命名约定。

Features | 主要功能:

  • Common naming styles - 常用命名风格
  • Style detection and conversion - 风格检测和转换
  • Separator configuration - 分隔符配置

Usage Examples | 使用示例:

// Get separator
String sep = NamingCase.SNAKE_CASE.getSeparator(); // "_"

// Check capitalization
boolean cap = NamingCase.PASCAL_CASE.isCapitalized(); // true

Supported Styles | 支持的风格:

  • CAMEL_CASE: camelCase - 小驼峰
  • PASCAL_CASE: PascalCase - 大驼峰/帕斯卡
  • SNAKE_CASE: snake_case - 蛇形
  • UPPER_SNAKE_CASE: UPPER_SNAKE_CASE - 大写蛇形/常量
  • KEBAB_CASE: kebab-case - 短横线
  • DOT_CASE: dot.case - 点分隔
  • PATH_CASE: path/case - 路径
  • TITLE_CASE: Title Case - 标题
  • SENTENCE_CASE: Sentence case - 句子

Security | 安全性:

  • Thread-safe: Yes (enum is immutable) - 线程安全: 是(枚举不可变)
Since:
JDK 25, opencode-base-string V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Enum Constant Details

    • CAMEL_CASE

      public static final NamingCase CAMEL_CASE
      小驼峰(camelCase)
    • PASCAL_CASE

      public static final NamingCase PASCAL_CASE
      大驼峰/帕斯卡(PascalCase)
    • SNAKE_CASE

      public static final NamingCase SNAKE_CASE
      蛇形(snake_case)
    • UPPER_SNAKE_CASE

      public static final NamingCase UPPER_SNAKE_CASE
      大写蛇形/常量(UPPER_SNAKE_CASE)
    • KEBAB_CASE

      public static final NamingCase KEBAB_CASE
      短横线(kebab-case)
    • DOT_CASE

      public static final NamingCase DOT_CASE
      点分隔(dot.case)
    • PATH_CASE

      public static final NamingCase PATH_CASE
      路径(path/case)
    • TITLE_CASE

      public static final NamingCase TITLE_CASE
      标题(Title Case) - 每个单词首字母大写,空格分隔
    • SENTENCE_CASE

      public static final NamingCase SENTENCE_CASE
      句子(Sentence case) - 首词首字母大写,其余小写,空格分隔
  • Method Details

    • values

      public static NamingCase[] 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 NamingCase 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
    • getSeparator

      public String getSeparator()
      Get the separator for this naming style. 获取此命名风格的分隔符。

      Examples | 示例:

      SNAKE_CASE.getSeparator() = "_"
      KEBAB_CASE.getSeparator() = "-"
      CAMEL_CASE.getSeparator() = ""
      
      Returns:
      separator string | 分隔符字符串
    • isCapitalized

      public boolean isCapitalized()
      Check if first letter should be capitalized. 检查首字母是否应该大写。

      Examples | 示例:

      PASCAL_CASE.isCapitalized() = true
      CAMEL_CASE.isCapitalized() = false
      TITLE_CASE.isCapitalized() = true
      
      Returns:
      true if first letter is capitalized | 如果首字母大写则返回true
    • isCapitalizeWords

      public boolean isCapitalizeWords()
      Check if all words should be capitalized. 检查是否所有单词都应该大写。
      Returns:
      true if words are capitalized | 如果单词大写则返回true
    • isUpperCase

      public boolean isUpperCase()
      Check if the style uses uppercase. 检查风格是否使用全大写。
      Returns:
      true if uppercase | 如果全大写则返回true
    • hasSeparator

      public boolean hasSeparator()
      Check if the style has a separator. 检查风格是否有分隔符。
      Returns:
      true if has separator | 如果有分隔符则返回true