public class NamingCase extends Object
Constructor and Description |
---|
NamingCase() |
Modifier and Type | Method and Description |
---|---|
static String |
toCamelCase(CharSequence name)
将下划线方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
规则为: 单字之间不以空格或任何连接符断开 第一个单字首字母采用小写字母 后续单字的首字母亦用大写字母 例如:hello_world=》helloWorld |
static String |
toCamelCase(CharSequence name,
char symbol)
将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
|
static String |
toCamelCase(CharSequence name,
char symbol,
boolean otherCharToLower)
将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
|
static String |
toKebabCase(CharSequence str)
将驼峰式命名的字符串转换为短横连接方式。
如果转换前的驼峰式命名的字符串为空,则返回空字符串。 规则为: 单字之间横线线隔开 每个单字的首字母亦用小写字母 例如: |
static String |
toPascalCase(CharSequence name)
将下划线方式命名的字符串转换为帕斯卡式。
规则为: 单字之间不以空格或任何连接符断开 第一个单字首字母采用大写字母 后续单字的首字母亦用大写字母 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:hello_world=》HelloWorld |
static String |
toSymbolCase(CharSequence str,
char symbol)
将驼峰式命名的字符串转换为使用符号连接方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
|
static String |
toUnderlineCase(CharSequence str)
将驼峰式命名的字符串转换为下划线方式,又称SnakeCase、underScoreCase。
如果转换前的驼峰式命名的字符串为空,则返回空字符串。 规则为: 单字之间以下划线隔开 每个单字的首字母亦用小写字母 例如: |
public static String toUnderlineCase(CharSequence str)
HelloWorld=》hello_world Hello_World=》hello_world HelloWorld_test=》hello_world_test
str
- 转换前的驼峰式命名的字符串,也可以为下划线形式public static String toKebabCase(CharSequence str)
HelloWorld=》hello-world Hello_World=》hello-world HelloWorld_test=》hello-world-test
str
- 转换前的驼峰式命名的字符串,也可以为下划线形式public static String toSymbolCase(CharSequence str, char symbol)
str
- 转换前的驼峰式命名的字符串,也可以为符号连接形式symbol
- 连接符public static String toPascalCase(CharSequence name)
name
- 转换前的下划线大写方式命名的字符串public static String toCamelCase(CharSequence name)
name
- 转换前的下划线大写方式命名的字符串public static String toCamelCase(CharSequence name, char symbol)
name
- 转换前的自定义方式命名的字符串symbol
- 原字符串中的连接符连接符public static String toCamelCase(CharSequence name, char symbol, boolean otherCharToLower)
name
- 转换前的自定义方式命名的字符串symbol
- 原字符串中的连接符连接符otherCharToLower
- 其他非连接符后的字符是否需要转为小写Copyright © 2024. All rights reserved.