mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
转驼峰方法多次转换保持结果一致
This commit is contained in:
parent
23f4af9e57
commit
ca152cfdd8
@ -88,14 +88,16 @@ public class StringUtil {
|
||||
if (isBlank(string)) {
|
||||
return "";
|
||||
}
|
||||
String temp = string.toLowerCase();
|
||||
int strLen = temp.length();
|
||||
if(Character.isUpperCase(string.charAt(0))){
|
||||
string = string.toLowerCase();
|
||||
}
|
||||
int strLen = string.length();
|
||||
StringBuilder sb = new StringBuilder(strLen);
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
char c = temp.charAt(i);
|
||||
char c = string.charAt(i);
|
||||
if (c == '_') {
|
||||
if (++i < strLen) {
|
||||
sb.append(Character.toUpperCase(temp.charAt(i)));
|
||||
sb.append(Character.toUpperCase(string.charAt(i)));
|
||||
}
|
||||
} else {
|
||||
sb.append(c);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user