Skip to content

Commit

Permalink
Merge pull request #217 from 403f/tmpapijson
Browse files Browse the repository at this point in the history
对JSONResponse.java中的formatHyphen方法的优化
  • Loading branch information
TommyLemon authored Apr 10, 2021
2 parents 7d6226b + f4d8775 commit e9131e5
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 e9131e5

Please sign in to comment.