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

The following examples show how to use javax.lang.model.element.TypeElement#getAnnotationsByType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestEmptyContainer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: TestEmptyContainer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: TestEmptyContainer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: TestEmptyContainer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: TestEmptyContainer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: TestEmptyContainer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: TestEmptyContainer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 8
Source File: TestEmptyContainer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}