mirror of https://gitee.com/y_project/RuoYi.git
Merge branch 'master' of https://gitee.com/y_project/RuoYi
commit
87c38706cd
|
@ -259,38 +259,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||||
/**
|
/**
|
||||||
* 下划线转驼峰命名
|
* 下划线转驼峰命名
|
||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String s)
|
public static String toUnderScoreCase(String str) {
|
||||||
{
|
if (str == null) {
|
||||||
if (s == null)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean upperCase = false;
|
//前置字符是否大写
|
||||||
for (int i = 0; i < s.length(); i++)
|
boolean preCharIsUpperCase = true;
|
||||||
{
|
//当前字符是否大写
|
||||||
char c = s.charAt(i);
|
boolean curreCharIsUpperCase = true;
|
||||||
|
//下一字符是否大写
|
||||||
boolean nextUpperCase = true;
|
boolean nexteCharIsUpperCase = true;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
if (i < (s.length() - 1))
|
char c = str.charAt(i);
|
||||||
{
|
if (i > 0) {
|
||||||
nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
|
preCharIsUpperCase = Character.isUpperCase(str.charAt(i-1));;
|
||||||
|
} else {
|
||||||
|
preCharIsUpperCase = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curreCharIsUpperCase = Character.isUpperCase(c);
|
||||||
|
|
||||||
if ((i > 0) && Character.isUpperCase(c))
|
if (i < (str.length() - 1)) {
|
||||||
{
|
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
|
||||||
if (!upperCase || !nextUpperCase)
|
|
||||||
{
|
|
||||||
sb.append(SEPARATOR);
|
|
||||||
}
|
|
||||||
upperCase = true;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
|
||||||
upperCase = false;
|
sb.append(SEPARATOR);
|
||||||
|
} else if ((i !=0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
|
||||||
|
sb.append(SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(Character.toLowerCase(c));
|
sb.append(Character.toLowerCase(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue