fix null point error

This commit is contained in:
oppofind 2019-12-23 20:39:27 +08:00
parent ec59855850
commit 75b5742973
2 changed files with 5 additions and 5 deletions

View File

@ -1007,10 +1007,10 @@ public class SourceBuilder {
String mockValue = ""; String mockValue = "";
if (DocClassUtil.isPrimitive(simpleTypeName)) { if (DocClassUtil.isPrimitive(simpleTypeName)) {
mockValue = paramsComments.get(paraName); mockValue = paramsComments.get(paraName);
if(mockValue.contains("|")){ if (Objects.nonNull(mockValue) && mockValue.contains("|")) {
mockValue = mockValue.substring(mockValue.lastIndexOf("|") + 1, mockValue.length()); mockValue = mockValue.substring(mockValue.lastIndexOf("|") + 1, mockValue.length());
} else { } else {
mockValue =""; mockValue = "";
} }
if (StringUtil.isEmpty(mockValue)) { if (StringUtil.isEmpty(mockValue)) {
mockValue = DocUtil.getValByTypeAndFieldName(simpleTypeName, paraName, true); mockValue = DocUtil.getValByTypeAndFieldName(simpleTypeName, paraName, true);
@ -1176,8 +1176,8 @@ public class SourceBuilder {
if (StringUtil.isEmpty(comment)) { if (StringUtil.isEmpty(comment)) {
comment = NO_COMMENTS_FOUND; comment = NO_COMMENTS_FOUND;
} else { } else {
if(comment.contains("|")){ if (comment.contains("|")) {
comment = comment.substring(0,comment.indexOf("|")); comment = comment.substring(0, comment.indexOf("|"));
} }
} }
List<JavaAnnotation> annotations = parameter.getAnnotations(); List<JavaAnnotation> annotations = parameter.getAnnotations();

View File

@ -181,7 +181,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate {
String typeName = parameter.getType().getGenericCanonicalName(); String typeName = parameter.getType().getGenericCanonicalName();
String simpleName = parameter.getType().getValue().toLowerCase(); String simpleName = parameter.getType().getValue().toLowerCase();
String fullTypeName = parameter.getType().getFullyQualifiedName(); String fullTypeName = parameter.getType().getFullyQualifiedName();
JavaClass javaClass = builder.getClassByName(fullTypeName); JavaClass javaClass = builder.getJavaProjectBuilder().getClassByName(fullTypeName);
if (!DocClassUtil.isMvcIgnoreParams(typeName)) { if (!DocClassUtil.isMvcIgnoreParams(typeName)) {
if (!paramTagMap.containsKey(paramName) && DocClassUtil.isPrimitive(fullTypeName) && isStrict) { if (!paramTagMap.containsKey(paramName) && DocClassUtil.isPrimitive(fullTypeName) && isStrict) {
throw new RuntimeException("ERROR: Unable to find javadoc @param for actual param \"" throw new RuntimeException("ERROR: Unable to find javadoc @param for actual param \""