本文整理汇总了Java中com.thoughtworks.qdox.model.JavaMethod.getTagsByName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMethod.getTagsByName方法的具体用法?Java JavaMethod.getTagsByName怎么用?Java JavaMethod.getTagsByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.qdox.model.JavaMethod
的用法示例。
在下文中一共展示了JavaMethod.getTagsByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processParameters
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
getLog().warn(String.format(
"No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}
示例2: processParameters
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().stream().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
throw new RuntimeException(String.format("No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}
示例3: processParameters
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private void processParameters(JavaMethod javaMethod, ObjectNode methodNode, String method, DocletTag tag) {
ArrayNode parameters = mapper.createArrayNode();
methodNode.set("parameters", parameters);
boolean required = true;
for (JavaParameter javaParameter : javaMethod.getParameters()) {
ObjectNode individualParameterNode = mapper.createObjectNode();
Optional<JavaAnnotation> optional = javaParameter.getAnnotations().stream().filter(
annotation -> annotation.getType().getName().equals(PATH_PARAM) ||
annotation.getType().getName().equals(QUERY_PARAM)).findAny();
JavaAnnotation pathType = optional.orElse(null);
String annotationName = javaParameter.getName();
if (pathType != null) { //the parameter is a path or query parameter
individualParameterNode.put("name",
pathType.getNamedParameter("value")
.toString().replace("\"", ""));
if (pathType.getType().getName().equals(PATH_PARAM)) {
individualParameterNode.put("in", "path");
} else if (pathType.getType().getName().equals(QUERY_PARAM)) {
individualParameterNode.put("in", "query");
}
individualParameterNode.put("type", getType(javaParameter.getType()));
} else { // the parameter is a body parameter
individualParameterNode.put("name", annotationName);
individualParameterNode.put("in", "body");
// Adds the reference to the Json model for the input
// that goes in the post or put operation
if (tag != null && (method.toLowerCase().equals("post") ||
method.toLowerCase().equals("put"))) {
ObjectNode schema = mapper.createObjectNode();
tag.getParameters().forEach(param -> {
schema.put("$ref", "#/definitions/" + param);
});
individualParameterNode.set("schema", schema);
}
}
for (DocletTag p : javaMethod.getTagsByName("param")) {
if (p.getValue().contains(annotationName)) {
String description = "";
if (p.getValue().split(" ", 2).length >= 2) {
description = p.getValue().split(" ", 2)[1].trim();
if (description.contains("optional")) {
required = false;
}
} else {
getLog().warn(String.format(
"No description for parameter \"%s\" in " +
"method \"%s\" in %s (line %d)",
p.getValue(), javaMethod.getName(),
javaMethod.getDeclaringClass().getName(),
javaMethod.getLineNumber()));
}
individualParameterNode.put("description", description);
}
}
individualParameterNode.put("required", required);
parameters.add(individualParameterNode);
}
}