add getNormalTagComments method

This commit is contained in:
oppofind 2019-10-18 00:10:49 +08:00
parent bc35811069
commit bb8d3035ef
1 changed files with 40 additions and 8 deletions

View File

@ -81,7 +81,6 @@ public class DocUtil {
fieldValue.put("version-string", enFaker.app().version());
}
/**
@ -262,6 +261,7 @@ public class DocUtil {
/**
* obtain params comments
*
* @param javaMethod JavaMethod
* @param tagName java comments tag
* @param className class name
@ -274,7 +274,7 @@ public class DocUtil {
String value = docletTag.getValue();
if (StringUtil.isEmpty(value)) {
throw new RuntimeException("ERROR: #" + javaMethod.getName()
+ "() - bad @"+tagName+" javadoc from " + className);
+ "() - bad @" + tagName + " javadoc from " + className + ", must be add comment if you use it.");
}
String pName;
String pValue;
@ -291,4 +291,36 @@ public class DocUtil {
}
return paramTagMap;
}
/**
* obtain java doc tags comments,like apiNote
*
* @param javaMethod JavaMethod
* @param tagName java comments tag
* @param className class name
* @return Map
*/
public static String getNormalTagComments(final JavaMethod javaMethod, final String tagName, final String className) {
Map<String, String> map = getParamsComments(javaMethod, tagName, className);
return getFirstKeyAndValue(map);
}
/**
* Get the first element of a map.
*
* @param map map
* @return String
*/
public static String getFirstKeyAndValue(Map<String, String> map) {
String value = null;
if (map != null && map.size() > 0) {
Map.Entry<String, String> entry = map.entrySet().iterator().next();
if (entry != null) {
value = entry.getKey() + entry.getValue();
value = value.replace("\r\n", "<br/>");
value = value.replace("\r", "<br/>");
}
}
return value;
}
}