Skip to content

Commit

Permalink
对JSONResponse.java中的formatHyphen方法的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
403f committed Apr 10, 2021
1 parent 7d6226b commit f4d8775
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions APIJSONORM/src/main/java/apijson/JSONResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
Expand Down Expand Up @@ -502,23 +503,17 @@ public static String formatColon(@NotNull String key) {
* @return
*/
public static String formatHyphen(@NotNull String key, boolean firstCase) {
boolean first = true;
int index;

String name = "";
String part;
do {
index = key.indexOf("-");
part = index < 0 ? key : key.substring(0, index);

name += firstCase && first == false ? StringUtil.firstCase(part, true) : part;
key = key.substring(index + 1);

first = false;
}
while (index >= 0);
StringTokenizer parts = new StringTokenizer(key, "-");
name += parts.nextToken();
while(parts.hasMoreTokens())
{
String part = parts.nextToken();
name += firstCase ? StringUtil.firstCase(part, true) : part;
}

return name;
return name;
}


Expand Down

0 comments on commit f4d8775

Please sign in to comment.