公众号:踏歌的 Java Daily
public static List toListCamelCase(List<Map<String, Object>> list) {
if (list != null) {
for (int i = 0; i < list.size(); ++i) {
Map<String, Object> map = list.get(i);
Map<String, Object> newMap = new HashMap();
Iterator var5 = map.keySet().iterator();
while (var5.hasNext()) {
String columnName = (String) var5.next();
Object obj = map.get(columnName);
columnName = toCamelCase(columnName);
newMap.put(columnName, obj);
}
list.set(i, newMap);
}
}
return list;
}
public static String toCamelCase(String s) {
if (s == null) {
return null;
} else {
s = s.toLowerCase();
StringBuilder sb = new StringBuilder(s.length());
boolean upperCase = false;
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (c == '_') {
upperCase = true;
} else if (upperCase) {
sb.append(Character.toUpperCase(c));
upperCase = false;
} else {
sb.append(c);
}
}
return sb.toString();
}
}