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


Java JavaMethod类代码示例

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


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

示例1: getJavadocComments

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
protected String getJavadocComments(final ITestNGMethod method) {

        try {
            final Method m = method.getMethod();
            final String javaClass = m.getDeclaringClass().getName();
            final String javaMethod = m.getName();
            final JavaClass jc = getJavaDocBuilder(m.getDeclaringClass()).getClassByName(javaClass);
            final Class<?>[] types = method.getMethod().getParameterTypes();
            final Type[] qdoxTypes = new Type[types.length];
            for (int i = 0; i < types.length; i++) {
                final String type = getType(types[i]);
                final int dim = getDim(types[i]);
                qdoxTypes[i] = new Type(type, dim);
            }

            final JavaMethod jm = jc.getMethodBySignature(javaMethod, qdoxTypes);
            return jm.getComment();
        } catch (final Throwable e) {
            logger.error("Exception loading the javadoc comments for : " + method.getMethodName() + e);
            return null;
        }

    }
 
开发者ID:tarun3kumar,项目名称:seleniumtestsframework,代码行数:24,代码来源:SeleniumTestsReporter.java

示例2: collectTestMethods

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
private static Sequence<TestMethod> collectTestMethods(Class aClass, Sequence<Method> methods) throws IOException {
    final Option<JavaClass> javaClass = getJavaClass(aClass);
    if (javaClass.isEmpty()) {
        return empty();
    }

    Map<String, List<JavaMethod>> sourceMethodsByName = getMethods(javaClass.get()).toMap(sourceMethodName());
    Map<String, List<Method>> reflectionMethodsByName = methods.toMap(reflectionMethodName());

    List<TestMethod> testMethods = new ArrayList<TestMethod>();
    TestMethodExtractor extractor = new TestMethodExtractor();
    for (String name : sourceMethodsByName.keySet()) {
        List<JavaMethod> javaMethods = sourceMethodsByName.get(name);
        List<Method> reflectionMethods = reflectionMethodsByName.get(name);
        testMethods.add(extractor.toTestMethod(aClass, javaMethods.get(0), reflectionMethods.get(0)));
        // TODO: If people overload test methods we will have to use the full name rather than the short name
    }

    Sequence<TestMethod> myTestMethods = sequence(testMethods);
    Sequence<TestMethod> parentTestMethods = collectTestMethods(aClass.getSuperclass(), methods);

    return myTestMethods.join(parentTestMethods);
}
 
开发者ID:bodar,项目名称:yatspec,代码行数:24,代码来源:TestParser.java

示例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 RuntimeGeradorException e) {
			throw new GeradorException("", e);
		}
	}
	
	return paramsReflect;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例4: 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;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例5: 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;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:DomainModelLoaderFactory.java

示例6: 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;
}
 
开发者ID:mojohaus,项目名称:servicedocgen-maven-plugin,代码行数:26,代码来源:JMethod.java

示例7: 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;
}
 
开发者ID:sergypv,项目名称:thrift-pojo-generator-maven-plugin,代码行数:24,代码来源:ThriftPojoGenerator.java

示例8: usecase

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
@Test
public void usecase() {
    JavaProjectBuilder builder = new JavaProjectBuilder();
    // Adding all .java files in a source tree (recursively).
    builder.addSourceTree(new File("/Users/Arnauld/Projects/cucumber-contrib/src/test/java/sample/coffeemachine"));

    for(JavaPackage pkg : builder.getPackages()) {
        System.out.println("::: " + pkg.getName());
        for(JavaClass klazz : pkg.getClasses()) {
            System.out.println(" :: " + klazz);
            for(JavaMethod method : klazz.getMethods()) {
                System.out.println("  : " + method.getAnnotations());
            }
        }
    }
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:17,代码来源:GrammarGenTest.java

示例9: main

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
public static void main(String[] args) {
        JavaProjectBuilder builder = new JavaProjectBuilder();
        try {
            JavaSource src = builder.addSource(new File(
                    "/Users/bingoohuang/github/java-sandbox/src/main/java/org/n3r/sandbox/qdox/DemoJava.java"));
            JavaPackage pkg = src.getPackage();
            String name = pkg.getName();
            String toString = pkg.toString();
            JavaPackage parent = pkg.getParentPackage();
            Collection<JavaClass> classes = pkg.getClasses();
            List<JavaMethod> methods = classes.iterator().next().getMethods();
            for (JavaMethod method : methods) {
                System.out.println("Method Name : " + method.getName());
            }
            System.out.println("pkg name : " + name);
            System.out.println("pkg to String : " + toString);
            System.out.println("pkg parent name : " + parent);

//            Method Name : printName
//            Method Name : createListOfNames
//            pkg name : org.n3r.sandbox.qdox
//            pkg to String : package org.n3r.sandbox.qdox
//            pkg parent name : null
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:28,代码来源:QDoxDemo.java

示例10: createResource

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
public JavaFile createResource(JavaClass jaxRsClass) {
	// find path annotation
	JavaAnnotation jaxRsPath = null;
	JavaAnnotation jaxRsConsumes = null;
	for (JavaAnnotation annotation : jaxRsClass.getAnnotations()) {
		String annotationType = annotation.getType().getFullyQualifiedName();
		if (annotationType.equals(Path.class.getName())) {
			jaxRsPath = annotation;
		} else if (annotationType.equals(Consumes.class.getName())) {
			jaxRsConsumes = annotation;
		}
	}
	if (jaxRsPath == null) return null; // no a valid JAX RS resource
	if (jaxRsClass.getName().matches(settings.getExcludedClassNamesRegex())) return null;

	System.out.println(jaxRsClass.getName());
	TypeSpec.Builder retrofitResourceBuilder = TypeSpec
			.interfaceBuilder(jaxRsClass.getName())
			.addModifiers(Modifier.PUBLIC);
	addAboutJavadoc(retrofitResourceBuilder);

	for (JavaMethod jaxRsMethod : jaxRsClass.getMethods()) {
		Collection<MethodSpec> retrofitMethods = createMethod(jaxRsClass, jaxRsMethod, jaxRsPath, jaxRsConsumes);
		if (retrofitMethods != null) {
			for (MethodSpec method : retrofitMethods) {
				retrofitResourceBuilder.addMethod(method);
			}
		}
	}

	return JavaFile.builder(settings.getPackageName(), retrofitResourceBuilder.build()).build();
}
 
开发者ID:Maddoc42,项目名称:JaxRs2Retrofit,代码行数:33,代码来源:RetrofitGenerator.java

示例11: 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

示例12: annotations

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

示例13: getBooleanValue

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
@Override
public Boolean getBooleanValue(final JavaMethod javaMethod, final String annotName, final String attribute) throws GeradorException {
	Object object = getAnnotationValue(javaMethod, annotName, attribute);
	Boolean boolValue=booleanValue(object);
	
	return boolValue;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:8,代码来源:DomainModelLoaderFactory.java

示例14: getAnnotationValue

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
public Object getAnnotationValue(final BeanProperty beanProperty, final String annotName, final String attribute) throws GeradorException {
	
	JavaMethod method = beanProperty.getAccessor();
	if (method == null) {
		method = beanProperty.getMutator();
	}
	
	return this.getAnnotationValue(method, annotName, attribute);
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:10,代码来源:DomainModelLoaderFactory.java

示例15: fixQDoxAnnotations

import com.thoughtworks.qdox.model.JavaMethod; //导入依赖的package包/类
/**
 * Atribui os valores default para cada atributo das anotações. Aparentemente, por um bug, o QDox não consegue reconhecer
 * valores default quando o atributo não é informado.
 * 
 * @param javaClass
 * @throws ClassNotFoundException
 */
protected void fixQDoxAnnotations(JavaClass javaClass) throws ClassNotFoundException {
	fixQDoxAnnotations(javaClass.getAnnotations());

	JavaMethod[] methods = javaClass.getMethods();

	for (JavaMethod javaMethod : methods) {
		fixQDoxAnnotations(javaMethod.getAnnotations());
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:17,代码来源:DomainModelLoaderFactory.java


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