本文整理汇总了Java中com.thoughtworks.qdox.model.JavaMethod.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMethod.getParameters方法的具体用法?Java JavaMethod.getParameters怎么用?Java JavaMethod.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.qdox.model.JavaMethod
的用法示例。
在下文中一共展示了JavaMethod.getParameters方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParams
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
protected Class[] getParams(final JavaMethod javaMethod) throws GeradorException {
final JavaParameter[] params = javaMethod.getParameters();
final Class[] paramsReflect = new Class[params.length];
int i = 0;
for (final JavaParameter javaParameter : params) {
Class clazz;
try {
clazz = forName(javaParameter.getType().getValue());
paramsReflect[i++] = clazz;
} catch (final RuntimeGeradorException e) {
throw new GeradorException("", e);
}
}
return paramsReflect;
}
示例2: getParams
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
protected Class[] getParams(JavaMethod javaMethod) throws GeradorException {
JavaParameter[] params = javaMethod.getParameters();
Class[] paramsReflect = new Class[params.length];
int i=0;
for (JavaParameter javaParameter : params) {
Class clazz;
try {
clazz = forName(javaParameter.getType().getFullyQualifiedName());
paramsReflect[i++] = clazz;
} catch (GeradorException e) {
throw new GeradorException("",e);
}
}
return paramsReflect;
}
示例3: getParams
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
protected Class[] getParams(final JavaMethod javaMethod) throws GeradorException {
final JavaParameter[] params = javaMethod.getParameters();
final Class[] paramsReflect = new Class[params.length];
int i = 0;
for (final JavaParameter javaParameter : params) {
Class clazz;
try {
clazz = forName(javaParameter.getType().getValue());
paramsReflect[i++] = clazz;
} catch (final GeradorException e) {
throw new GeradorException("", e);
}
}
return paramsReflect;
}
示例4: findSourceMethod
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private static JavaMethod findSourceMethod( JavaClass sourceClass, Method byteMethod )
{
for ( JavaMethod sourceMethod : sourceClass.getMethods() )
{
if ( sourceMethod.getName().equals( byteMethod.getName() ) )
{
List<JavaParameter> sourceParameters = sourceMethod.getParameters();
Class<?>[] byteParameters = byteMethod.getParameterTypes();
if ( sourceParameters.size() == byteParameters.length )
{
for ( int i = 0; i < byteParameters.length; i++ )
{
String byteTypeName = byteParameters[i].getName();
String sourceTypeName = sourceParameters.get( i ).getType().getFullyQualifiedName();
if ( !byteTypeName.equals( sourceTypeName ) )
{
return null;
}
}
return sourceMethod;
}
}
}
return null;
}
示例5: generateClassBuilderFor
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private PojoClass generateClassBuilderFor(JavaClass javaClass, STGroup template) throws IOException {
for (JavaMethod method : javaClass.getMethods()) {
if (isAllArgumentsConstructor(javaClass, method)) {
PojoClass pojo = new PojoClass(getGeneratedClassPackage(javaClass), getPojoClassName(javaClass.getName()), javaClass.getFullyQualifiedName(),
interfaceName, getPojoSuperclass(javaClass), Boolean.parseBoolean(includeFieldsEnum));
for (JavaParameter p : method.getParameters()) {
if (p.getType().isA(new Type(POJO_CLASS_MAP))) {
pojo.addMapParameter(p.getType().toGenericString(), p.getName());
} else if(p.getType().isA(new Type(POJO_CLASS_LIST))){
pojo.addListParameter(p.getType().toGenericString(), p.getName());
} else if(p.getType().isA(new Type(POJO_CLASS_SET))){
pojo.addSetParameter(p.getType().toGenericString(), p.getName());
}else {
pojo.addParameter(p.getType().toGenericString(), p.getName());
}
}
return pojo;
}
}
return null;
}
示例6: 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);
}
}
示例7: createMethod
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private Collection<MethodSpec> createMethod(
JavaClass jaxRsClass,
JavaMethod jaxRsMethod,
JavaAnnotation jaxRsPath,
JavaAnnotation jaxRsConsumes) {
RetrofitMethodBuilder retrofitMethodBuilder = new RetrofitMethodBuilder(
jaxRsMethod.getName(),
settings);
// find method type and path
JavaAnnotation jaxRsMethodPath = null;
HttpMethod httpMethod = null;
for (JavaAnnotation annotation : jaxRsMethod.getAnnotations()) {
String annotationType = annotation.getType().getFullyQualifiedName();
if (annotationType.equals(Path.class.getName())) {
jaxRsMethodPath = annotation;
} else if (annotationType.equals(Consumes.class.getName())) {
jaxRsConsumes = annotation;
} else if (httpMethod == null) {
httpMethod = HttpMethod.forJaxRsClassName(annotation.getType().getFullyQualifiedName());
}
}
if (httpMethod == null) return null; // not a valid resource method
EvaluatingVisitor evaluatingVisitor = new SimpleEvaluatingVisitor(jaxRsClass);
// add path
retrofitMethodBuilder.addAnnotation(createPathAnnotation(evaluatingVisitor, httpMethod, jaxRsPath, jaxRsMethodPath));
// add content type
if (jaxRsConsumes != null) {
retrofitMethodBuilder.addAnnotation(createContentTypeAnnotation(evaluatingVisitor, jaxRsConsumes));
}
// create parameters
for (JavaParameter jaxRsParameter : jaxRsMethod.getParameters()) {
ParameterSpec spec = createParameter(jaxRsParameter);
if (spec != null) retrofitMethodBuilder.addParameter(spec);
}
// create return type
TypeName retrofitReturnType = createType(jaxRsMethod.getReturnType());
if (retrofitReturnType.equals(TypeName.VOID)) {
retrofitReturnType = ClassName.get(Response.class);
}
retrofitMethodBuilder.setReturnType(retrofitReturnType);
return retrofitMethodBuilder.build().values();
}
示例8: isAllArgumentsConstructor
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private boolean isAllArgumentsConstructor(JavaClass javaClass, JavaMethod method) {
return method.isConstructor()
&& method.getParameters().length > 0
&& !(method.getParameters().length == 1 && method.getParameters()[0].getType().getFullyQualifiedName()
.equals(javaClass.getFullyQualifiedName()));
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: createMethodModel
import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private EventMethodModel createMethodModel(JavaMethod method)
throws EventConventionException, ClassNotFoundException {
JavaClass clazz = method.getParentClass();
//Check EventProducer conventions
if (!method.getReturnType().isVoid()) {
throw new EventConventionException("All methods of interface "
+ clazz.getFullyQualifiedName() + " must have return type 'void'!");
}
String methodSig = clazz.getFullyQualifiedName() + "." + method.getCallSignature();
JavaParameter[] params = method.getParameters();
if (params.length < 1) {
throw new EventConventionException("The method " + methodSig
+ " must have at least one parameter: 'Object source'!");
}
Type firstType = params[0].getType();
if (firstType.isPrimitive() || !"source".equals(params[0].getName())) {
throw new EventConventionException("The first parameter of the method " + methodSig
+ " must be: 'Object source'!");
}
//build method model
DocletTag tag = method.getTagByName("event.severity");
EventSeverity severity;
if (tag != null) {
severity = EventSeverity.valueOf(tag.getValue());
} else {
severity = EventSeverity.INFO;
}
EventMethodModel methodMeta = new EventMethodModel(
method.getName(), severity);
if (params.length > 1) {
for (int j = 1, cj = params.length; j < cj; j++) {
JavaParameter p = params[j];
Class<?> type;
JavaClass pClass = p.getType().getJavaClass();
if (p.getType().isPrimitive()) {
type = PRIMITIVE_MAP.get(pClass.getName());
if (type == null) {
throw new UnsupportedOperationException(
"Primitive datatype not supported: " + pClass.getName());
}
} else {
String className = pClass.getFullyQualifiedName();
type = Class.forName(className);
}
methodMeta.addParameter(type, p.getName());
}
}
Type[] exceptions = method.getExceptions();
if (exceptions != null && exceptions.length > 0) {
//We only use the first declared exception because that is always thrown
JavaClass cl = exceptions[0].getJavaClass();
methodMeta.setExceptionClass(cl.getFullyQualifiedName());
methodMeta.setSeverity(EventSeverity.FATAL); //In case it's not set in the comments
}
return methodMeta;
}