mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
35 lines
741 B
Java
35 lines
741 B
Java
package com.avaje.ebean.util;
|
|
|
|
public class CamelCaseHelper {
|
|
|
|
/**
|
|
* To camel from underscore.
|
|
*
|
|
* @param underscore
|
|
* the underscore
|
|
*
|
|
* @return the string
|
|
*/
|
|
public static String toCamelFromUnderscore(String underscore) {
|
|
|
|
String[] vals = underscore.split("_");
|
|
if (vals.length == 1) {
|
|
return underscore;
|
|
}
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
for (int i = 0; i < vals.length; i++) {
|
|
String lower = vals[i].toLowerCase();
|
|
if (i > 0) {
|
|
char c = Character.toUpperCase(lower.charAt(0));
|
|
result.append(c);
|
|
result.append(lower.substring(1));
|
|
} else {
|
|
result.append(lower);
|
|
}
|
|
}
|
|
|
|
return result.toString();
|
|
}
|
|
}
|