代码格式化

master
RuoYi 6 years ago committed by Limy
parent 59c529c652
commit 69ff1efdb4

@ -259,8 +259,10 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
/** /**
* 线 * 线
*/ */
public static String toUnderScoreCase(String str) { public static String toUnderScoreCase(String str)
if (str == null) { {
if (str == null)
{
return null; return null;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -270,23 +272,31 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
boolean curreCharIsUpperCase = true; boolean curreCharIsUpperCase = true;
// 下一字符是否大写 // 下一字符是否大写
boolean nexteCharIsUpperCase = true; boolean nexteCharIsUpperCase = true;
for (int i = 0; i < str.length(); i++) { for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i); char c = str.charAt(i);
if (i > 0) { if (i > 0)
preCharIsUpperCase = Character.isUpperCase(str.charAt(i-1));; {
} else { preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
}
else
{
preCharIsUpperCase = false; preCharIsUpperCase = false;
} }
curreCharIsUpperCase = Character.isUpperCase(c); curreCharIsUpperCase = Character.isUpperCase(c);
if (i < (str.length() - 1)) { if (i < (str.length() - 1))
{
nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
} }
if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) { if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
{
sb.append(SEPARATOR); sb.append(SEPARATOR);
} else if ((i !=0 && !preCharIsUpperCase) && curreCharIsUpperCase) { }
else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
{
sb.append(SEPARATOR); sb.append(SEPARATOR);
} }
sb.append(Character.toLowerCase(c)); sb.append(Character.toLowerCase(c));

Loading…
Cancel
Save