!345 驼峰处理优化

Merge pull request !345 from tangxin/main
This commit is contained in:
Michael Yang 2023-09-18 11:33:29 +00:00 committed by Gitee
commit f5d20f5774
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 5 deletions

View File

@ -80,7 +80,7 @@ public class FlexWrapperFactory implements ObjectWrapperFactory {
@Override
public String findProperty(String name, boolean useCamelCaseMapping) {
return useCamelCaseMapping && name.contains("_") ? StringUtil.underlineToCamel(name) : name;
return useCamelCaseMapping && ( Character.isUpperCase(name.charAt(0)) || name.contains("_")) ? StringUtil.underlineToCamel(name) : name;
}
}

View File

@ -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);