Java Code Examples for javax.lang.model.element.TypeElement.getAnnotationsByType()

The following are Jave code examples for showing how to use getAnnotationsByType() of the javax.lang.model.element.TypeElement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: TestEmptyContainer.java   View Source Code Vote up 6 votes
public boolean process(Set<? extends TypeElement> annotations,
                       RoundEnvironment roundEnv) {
    if (!roundEnv.processingOver()) {
        boolean hasRun = false;
        for (Element element : roundEnv.getRootElements())
            for (TypeElement te : typesIn(element.getEnclosedElements()))
                if (te.getQualifiedName().contentEquals("TestEmptyContainer.T2")) {
                    hasRun = true;
                    Foo[] foos = te.getAnnotationsByType(Foo.class);
                    System.out.println("  " + te);
                    System.out.println("  " + Arrays.asList(foos));
                    Assert.check(foos.length == 1, "Should find one @Foo");
                    Assert.check(foos[0].value() == 1, "Should find @Foo(1)");
                }
        if (!hasRun)
            throw new RuntimeException("Annotation processor couldn't find class T2, test broken!");
    }
    return true;
}