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


Java JavaMethod.getName方法代码示例

本文整理汇总了Java中com.thoughtworks.qdox.model.JavaMethod.getName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaMethod.getName方法的具体用法?Java JavaMethod.getName怎么用?Java JavaMethod.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thoughtworks.qdox.model.JavaMethod的用法示例。


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

示例1: sourceMethodName

import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private static Callable1<JavaMethod, String> sourceMethodName() {
    return new Callable1<JavaMethod, String>() {
        @Override
        public String call(JavaMethod javaMethod) throws Exception {
            return javaMethod.getName();
        }
    };
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:9,代码来源:TestParser.java

示例2: 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();
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:50,代码来源:RetrofitGenerator.java

示例3: 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;
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:58,代码来源:EventProducerCollector.java


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