当前位置: 首页>>代码示例>>Java>>正文


Java JavaParameter类代码示例

本文整理汇总了Java中com.thoughtworks.qdox.model.JavaParameter的典型用法代码示例。如果您正苦于以下问题:Java JavaParameter类的具体用法?Java JavaParameter怎么用?Java JavaParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaParameter类属于com.thoughtworks.qdox.model包,在下文中一共展示了JavaParameter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParams

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例2: getParams

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例3: getParams

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例4: findSourceMethod

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:mojohaus,项目名称:servicedocgen-maven-plugin,代码行数:26,代码来源:JMethod.java

示例5: MethodLocation

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的package包/类
/**
 * Creates a new MethodLocation with the supplied package, class and member names.
 *
 * @param packageName The name of the package for a class potentially holding JavaDoc. Cannot be {@code null}.
 * @param className   The (simple) name of a class. Cannot be null or empty.
 * @param memberName  The name of a (method or) field. Cannot be null or empty.
 * @param classXmlName  The name given as the {@link XmlType#name()} value of an annotation placed on the Class,
 *                      or {@code  null} if none is provided.
 * @param memberXmlName The name given as the {@link XmlElement#name()} or {@link XmlAttribute#name()} value of
 *                      an annotation placed on this Field, or {@code null} if none is provided.
 */
public MethodLocation(final String packageName,
        final String className,
        final String classXmlName,
        final String memberName,
        final String memberXmlName,
        final List<JavaParameter> parameters) {

    super(packageName, className, classXmlName, memberName, memberXmlName);

    // Check sanity
    Validate.notNull(parameters, "parameters");

    // Stringify the parameter types
    if (parameters.size() > 0) {
        final StringBuilder builder = new StringBuilder();

        for (JavaParameter current : parameters) {
            builder.append(current.getType().getFullyQualifiedName()).append(PARAMETER_SEPARATOR);
        }
        this.parameters = "(" + builder.substring(0, builder.lastIndexOf(PARAMETER_SEPARATOR)) + ")";
    }
}
 
开发者ID:mojohaus,项目名称:jaxb2-maven-plugin,代码行数:34,代码来源:MethodLocation.java

示例6: generateClassBuilderFor

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:sergypv,项目名称:thrift-pojo-generator-maven-plugin,代码行数:24,代码来源:ThriftPojoGenerator.java

示例7: processParameters

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:64,代码来源:OnosSwaggerMojo.java

示例8: createMethod

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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();
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:50,代码来源:RetrofitGenerator.java

示例9: createParameter

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的package包/类
private ParameterSpec createParameter(
		JavaParameter jaxRsParameter) {

	// find first annotation which can be converted, others are ignored
	JavaAnnotation jaxRsAnnotation = null;
	ClassName annotationType = null;
	TypeName paramType = createType(jaxRsParameter.getJavaClass());

	for (JavaAnnotation annotation : jaxRsParameter.getAnnotations()) {
		annotationType = (ClassName) createType(annotation.getType());
		jaxRsAnnotation = annotation;
		if (settings.getParamConverterManager().hasConverter(annotationType)) break;
	}

	// find suitable converter
	ParamConverter converter = settings.getParamConverterManager().getConverter(annotationType);

	// if no converter was found, ignore annotation
	if (converter == null) {
		annotationType = ClassName.get(Void.class);
		converter = settings.getParamConverterManager().getConverter(annotationType);
	}

	// if still no converted is found, ignore parameter completely (should (TM) only happen when
	// void converter has been explicitly removed
	if (converter == null) return null;

	// convert annotation and param
	AnnotatedParam param = new AnnotatedParam(
			paramType,
			annotationType,
			(jaxRsAnnotation == null) ? new HashMap<String, Object>() : jaxRsAnnotation.getNamedParameterMap());

	AnnotatedParam convertedParam = converter.convert(param);
	if (convertedParam == null) return null;

	// create code
	ParameterSpec.Builder retrofitParamBuilder = ParameterSpec
			.builder(convertedParam.getParamType(), jaxRsParameter.getName());

	AnnotationSpec.Builder retrofitParamAnnotationBuilder = AnnotationSpec
			.builder(convertedParam.getAnnotationType());

	if (jaxRsAnnotation != null) {
		for (Map.Entry<String, Object> entry : convertedParam.getAnnotationParameterMap().entrySet()) {
			retrofitParamAnnotationBuilder.addMember(entry.getKey(), entry.getValue().toString());
		}
	}
	retrofitParamBuilder.addAnnotation(retrofitParamAnnotationBuilder.build());
	return retrofitParamBuilder.build();
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:52,代码来源:RetrofitGenerator.java

示例10: getParameter

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的package包/类
/**
 * @return the {@link JavaParameter} from source-code analysis. May be <code>null</code>.
 */
public JavaParameter getParameter()
{
    return this.parameter;
}
 
开发者ID:mojohaus,项目名称:servicedocgen-maven-plugin,代码行数:8,代码来源:JParameter.java

示例11: processParameters

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:63,代码来源:SwaggerGenerator.java

示例12: processParameters

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:64,代码来源:OnosSwaggerMojo.java

示例13: createMethodModel

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的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;
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:58,代码来源:EventProducerCollector.java

示例14: JParameter

import com.thoughtworks.qdox.model.JavaParameter; //导入依赖的package包/类
/**
 * The constructor.
 *
 * @param byteType - see {@link #getByteType()}.
 * @param byteAnnotations - see {@link #getByteAnnotations()}.
 * @param parameter - see {@link #getParameter()}.
 * @param comment - see {@link #getComment()}.
 * @param index the index of the parameter in the method arguments.
 */
public JParameter( GenericType<?> byteType, Annotation[] byteAnnotations, JavaParameter parameter, String comment,
                   int index )
{
    super( byteType, parameter.getJavaClass(), comment );
    this.parameter = parameter;
    this.byteAnnotations = byteAnnotations;
    this.index = index;
}
 
开发者ID:mojohaus,项目名称:servicedocgen-maven-plugin,代码行数:18,代码来源:JParameter.java


注:本文中的com.thoughtworks.qdox.model.JavaParameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。