Skip navigation links
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
hutool
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
cn.hutool.core.text
Class NamingCase
java.lang.Object
cn.hutool.core.text.NamingCase
public class NamingCase
extends Object
命名规则封装,主要是针对驼峰风格命名、连接符命名等的封装
Since:
5.7.10
Author:
looly
Constructor Summary
Constructors
Constructor and Description
NamingCase()
Method Summary
All Methods Static Methods Concrete Methods
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。
如果转换前的驼峰式命名的字符串为空,则返回空字符串。
规则为:
单字之间以下划线隔开
每个单字的首字母亦用小写字母
例如:
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
NamingCase
public NamingCase()
Method Detail
toUnderlineCase
public static String toUnderlineCase(CharSequence str)
将驼峰式命名的字符串转换为下划线方式,又称SnakeCase、underScoreCase。
如果转换前的驼峰式命名的字符串为空,则返回空字符串。
规则为:
单字之间以下划线隔开
每个单字的首字母亦用小写字母
例如:
HelloWorld=》hello_world
Hello_World=》hello_world
HelloWorld_test=》hello_world_test
Parameters:
str - 转换前的驼峰式命名的字符串,也可以为下划线形式
Returns:
转换后下划线方式命名的字符串
toKebabCase
public static String toKebabCase(CharSequence str)
将驼峰式命名的字符串转换为短横连接方式。
如果转换前的驼峰式命名的字符串为空,则返回空字符串。
规则为:
单字之间横线线隔开
每个单字的首字母亦用小写字母
例如:
HelloWorld=》hello-world
Hello_World=》hello-world
HelloWorld_test=》hello-world-test
Parameters:
str - 转换前的驼峰式命名的字符串,也可以为下划线形式
Returns:
转换后下划线方式命名的字符串
toSymbolCase
public static String toSymbolCase(CharSequence str,
char symbol)
将驼峰式命名的字符串转换为使用符号连接方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。
Parameters:
str - 转换前的驼峰式命名的字符串,也可以为符号连接形式
symbol - 连接符
Returns:
转换后符号连接方式命名的字符串
Since:
4.0.10
toPascalCase
public static String toPascalCase(CharSequence name)
将下划线方式命名的字符串转换为帕斯卡式。
规则为:
单字之间不以空格或任何连接符断开
第一个单字首字母采用大写字母
后续单字的首字母亦用大写字母
如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
例如:hello_world=》HelloWorld
Parameters:
name - 转换前的下划线大写方式命名的字符串
Returns:
转换后的驼峰式命名的字符串
toCamelCase
public static String toCamelCase(CharSequence name)
将下划线方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
规则为:
单字之间不以空格或任何连接符断开
第一个单字首字母采用小写字母
后续单字的首字母亦用大写字母
例如:hello_world=》helloWorld
Parameters:
name - 转换前的下划线大写方式命名的字符串
Returns:
转换后的驼峰式命名的字符串
toCamelCase
public static String toCamelCase(CharSequence name,
char symbol)
将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
Parameters:
name - 转换前的自定义方式命名的字符串
symbol - 原字符串中的连接符连接符
Returns:
转换后的驼峰式命名的字符串
Since:
5.7.17
toCamelCase
public static String toCamelCase(CharSequence name,
char symbol,
boolean otherCharToLower)
将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
Parameters:
name - 转换前的自定义方式命名的字符串
symbol - 原字符串中的连接符连接符
otherCharToLower - 其他非连接符后的字符是否需要转为小写
Returns:
转换后的驼峰式命名的字符串
Skip navigation links
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Copyright © 2024. All rights reserved.
|