
com.kyle.component.kdb.annotation.compiler.CamelUtils Maven / Gradle / Ivy
package com.kyle.component.kdb.annotation.compiler;
/**
* @author Kyle
* @time 2021/5/13
*/
public class CamelUtils {
/**
* 下划线转驼峰,首字母小写
*
* @param name
* @return
*/
public static String camelNameLowerCase(String name) {
String camelName = camelNameUpperCase(name);
return camelName.substring(0, 1).toLowerCase() + camelName.substring(1);
}
/**
* 下划线转驼峰,首字母大写
*
* @param name
* @return
*/
public static String camelNameUpperCase(String name) {
StringBuilder result = new StringBuilder();
if (name == null || name.isEmpty()) {
return "";
} else if (!name.contains("_")) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
String camels[] = name.split("_");
for (String camel : camels) {
if (camel.isEmpty()) {
continue;
}
result.append(camel.substring(0, 1).toUpperCase());
result.append(camel.substring(1).toLowerCase());
}
return result.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy