Skip to content

Commit

Permalink
Fix Null point.
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed May 30, 2021
1 parent 2eb9708 commit 0a9f622
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
9 changes: 1 addition & 8 deletions src/main/java/com/power/doc/helper/JsonBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,7 @@ public static String buildJson(String typeName, String genericCanonicalName,
Object value = JavaClassUtil.getEnumValue(javaClass, Boolean.FALSE);
data0.append(value).append(",");
} else {
String[] gNameArr = DocClassUtil.getSimpleGicName(fieldGicName);
if (gNameArr.length > 0) {
String gName = gNameArr[0];
if (gName.length() == 1) {
String gicName = genericMap.get(gName) != null ? genericMap.get(gName) : globGicName[0];
fieldGicName = fieldGicName.replace(gName,gicName);
}
}
fieldGicName = DocUtil.formatFieldTypeGicName(genericMap, globGicName, fieldGicName);
data0.append(buildJson(subTypeName, fieldGicName, isResp, nextLevel, registryClasses, builder)).append(",");
}
}
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/power/doc/helper/ParamsBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,7 @@ public static List<ApiParam> buildParams(String className, String pre, int level
} else {
commonHandleParam(paramList, param, isRequired, NO_COMMENTS_FOUND + appendComment, since, strRequired);
}
String[] gNameArr = DocClassUtil.getSimpleGicName(fieldGicName);
if (gNameArr.length > 0) {
String gName = gNameArr[0];
if (gName.length() == 1) {
String gicName = genericMap.get(gName) != null ? genericMap.get(gName) : globGicName[0];
fieldGicName = fieldGicName.replace(gName,gicName);
}
}
fieldGicName = DocUtil.formatFieldTypeGicName(genericMap, globGicName, fieldGicName);
fieldPid = paramList.size() + pid;
paramList.addAll(buildParams(fieldGicName, preBuilder.toString(), nextLevel, isRequired,
isResp, registryClasses, projectBuilder, groupClasses, fieldPid, jsonRequest));
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/power/doc/utils/DocUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,31 @@ public static List<ApiDocDict> buildDictionary(ApiConfig config, JavaProjectBuil
return apiDocDictList;
}

/**
* Format field Type
* @param genericMap genericMap
* @param globGicName
* @param fieldGicName
* @return string
*/
public static String formatFieldTypeGicName(Map<String, String> genericMap, String[] globGicName, String fieldGicName) {
String[] gNameArr = DocClassUtil.getSimpleGicName(fieldGicName);
if (gNameArr.length > 0) {
String gName = gNameArr[0];
if (gName.length() == 1) {
String gicName = "";
if (Objects.nonNull(genericMap.get(gName))) {
gicName = genericMap.get(gName);
}
if (globGicName.length > 0) {
gicName = globGicName[0];
}
if (StringUtil.isNotEmpty(gicName)) {
fieldGicName = fieldGicName.replace(gName, gicName);
}
}
}
return fieldGicName;
}

}

0 comments on commit 0a9f622

Please sign in to comment.