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 |
toKebabCase(CharSequence text)
将驼峰式命名的字符串转换为短横连接方式
如果转换前的驼峰式命名的字符串为空,则返回空字符串
规则为:
单字之间横线线隔开
每个单字的首字母亦用小写字母
例如:
|
static String |
toPascalCase(CharSequence name)
将下划线方式命名的字符串转换为帕斯卡式
规则为:
单字之间不以空格或任何连接符断开
第一个单字首字母采用大写字母
后续单字的首字母亦用大写字母
如果转换前的下划线大写方式命名的字符串为空,则返回空字符串
例如:hello_world - HelloWorld
|
static String |
toSymbolCase(CharSequence text,
char symbol)
将驼峰式命名的字符串转换为使用符号连接方式如果转换前的驼峰式命名的字符串为空,则返回空字符串
|
static String |
toUnderlineCase(CharSequence text)
将驼峰式命名的字符串转换为下划线方式,又称SnakeCase、underScoreCase
如果转换前的驼峰式命名的字符串为空,则返回空字符串
规则为:
单字之间以下划线隔开
每个单字的首字母亦用小写字母
例如:
|
public static String toUnderlineCase(CharSequence text)
HelloWorld - hello_world Hello_World - hello_world HelloWorld_test - hello_world_test
text - 转换前的驼峰式命名的字符串,也可以为下划线形式public static String toKebabCase(CharSequence text)
HelloWorld - hello-world Hello_World - hello-world HelloWorld_test - hello-world-test
text - 转换前的驼峰式命名的字符串,也可以为下划线形式public static String toSymbolCase(CharSequence text, char symbol)
text - 转换前的驼峰式命名的字符串,也可以为符号连接形式symbol - 连接符public static String toPascalCase(CharSequence name)
name - 转换前的下划线大写方式命名的字符串public static String toCamelCase(CharSequence name)
name - 转换前的下划线大写方式命名的字符串Copyright © 2021. All rights reserved.