mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix code
This commit is contained in:
parent
f79dd096e2
commit
06c27a8cfe
@ -173,6 +173,18 @@ public class NamingCase {
|
||||
* @since 5.7.17
|
||||
*/
|
||||
public static String toCamelCase(final CharSequence name, final char symbol) {
|
||||
return toCamelCase(name, symbol, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将连接符方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。
|
||||
*
|
||||
* @param name 转换前的自定义方式命名的字符串
|
||||
* @param symbol 原字符串中的连接符连接符
|
||||
* @param otherCharToLower 其他非连接符后的字符是否需要转为小写
|
||||
* @return 转换后的驼峰式命名的字符串
|
||||
*/
|
||||
public static String toCamelCase(final CharSequence name, final char symbol, final boolean otherCharToLower) {
|
||||
if (null == name) {
|
||||
return null;
|
||||
}
|
||||
@ -191,7 +203,7 @@ public class NamingCase {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
upperCase = false;
|
||||
} else {
|
||||
sb.append(Character.toLowerCase(c));
|
||||
sb.append(otherCharToLower ? Character.toLowerCase(c) : c);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -47,4 +47,13 @@ public class NamingCaseTest {
|
||||
// https://gitee.com/dromara/hutool/issues/I5TVMU
|
||||
Assertions.assertEquals("t1C1", NamingCase.toUnderlineCase("t1C1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue3031Test() {
|
||||
String camelCase = NamingCase.toCamelCase("user_name,BIRTHDAY");
|
||||
Assertions.assertEquals("userName,birthday", camelCase);
|
||||
|
||||
camelCase = NamingCase.toCamelCase("user_name,BIRTHDAY", '_', false);
|
||||
Assertions.assertEquals("userName,BIRTHDAY", camelCase);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user