Search in sources :

Example 1 with Annotation

use of com.thoughtworks.qdox.model.Annotation in project maven-plugins by apache.

the class AbstractFixJavadocMojo method isInherited.

/**
     * Verify if a method has <code>&#64;java.lang.Override()</code> annotation or if it is an inherited method
     * from an interface or a super class. The goal is to handle <code>&#123;&#64;inheritDoc&#125;</code> tag.
     *
     * @param javaMethod not null
     * @return <code>true</code> if the method is inherited, <code>false</code> otherwise.
     * @throws MojoExecutionException if any
     */
private boolean isInherited(JavaMethod javaMethod) throws MojoExecutionException {
    if (javaMethod.getAnnotations() != null) {
        for (int i = 0; i < javaMethod.getAnnotations().length; i++) {
            Annotation annotation = javaMethod.getAnnotations()[i];
            if (annotation.toString().equals("@java.lang.Override()")) {
                return true;
            }
        }
    }
    Class<?> clazz = getClass(javaMethod.getParentClass().getFullyQualifiedName());
    List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz);
    for (Class<?> intface : interfaces) {
        if (isInherited(intface, javaMethod)) {
            return true;
        }
    }
    List<Class<?>> classes = ClassUtils.getAllSuperclasses(clazz);
    for (Class<?> superClass : classes) {
        if (isInherited(superClass, javaMethod)) {
            return true;
        }
    }
    return false;
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass) Annotation(com.thoughtworks.qdox.model.Annotation)

Example 2 with Annotation

use of com.thoughtworks.qdox.model.Annotation in project arrow by NetEase.

the class NeXMLSuiteResultWriter method getTestMethodAttr.

private String getTestMethodAttr(String attr, String className, ITestNGMethod method) {
    logger.info("className = " + className);
    String value = "";
    JavaClass cls = builder.getClassByName(className);
    JavaMethod[] mtds = cls.getMethods();
    logger.info("JavaMethod = " + mtds.toString());
    for (JavaMethod mtd : mtds) {
        if (mtd.getName().equals(method.getMethodName())) {
            Annotation[] annotations = mtd.getAnnotations();
            logger.info("Annotation = " + annotations.toString());
            for (Annotation ant : annotations) {
                logger.info("Annotation.getClass().getName() = " + ant.getClass().getName());
                String clss = ant.getType().getFullyQualifiedName();
                if (clss.equals("org.testng.annotations.Test")) {
                    Map<String, String> map = ant.getNamedParameterMap();
                    if (map.containsKey(attr)) {
                        value = map.get(attr);
                        value = value.substring(1, value.length() - 1);
                    }
                }
            }
            break;
        }
    }
    return value;
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass) JavaMethod(com.thoughtworks.qdox.model.JavaMethod) Annotation(com.thoughtworks.qdox.model.Annotation)

Aggregations

Annotation (com.thoughtworks.qdox.model.Annotation)2 JavaClass (com.thoughtworks.qdox.model.JavaClass)2 JavaMethod (com.thoughtworks.qdox.model.JavaMethod)1