Search in sources :

Example 1 with Documented

use of java.lang.annotation.Documented in project spring-loaded by spring-projects.

the class Play method doit.

public void doit() throws Exception {
    Class<?> clazz = Documented.class;
    System.out.println(clazz.getName());
    Method m = clazz.getMethod("annotationType");
    Documented d = Foo2.class.getAnnotation(Documented.class);
    System.out.println(m);
    System.out.println(d);
    System.out.println(m.getDeclaringClass().getName());
}
Also used : Documented(java.lang.annotation.Documented) Method(java.lang.reflect.Method)

Example 2 with Documented

use of java.lang.annotation.Documented in project auto by google.

the class MoreElementsTest method getAnnotationMirror.

@Test
public void getAnnotationMirror() {
    TypeElement element = compilation.getElements().getTypeElement(AnnotatedAnnotation.class.getCanonicalName());
    Optional<AnnotationMirror> documented = MoreElements.getAnnotationMirror(element, Documented.class);
    Optional<AnnotationMirror> innerAnnotation = MoreElements.getAnnotationMirror(element, InnerAnnotation.class);
    Optional<AnnotationMirror> suppressWarnings = MoreElements.getAnnotationMirror(element, SuppressWarnings.class);
    expect.that(documented).isPresent();
    expect.that(innerAnnotation).isPresent();
    expect.that(suppressWarnings).isAbsent();
    Element annotationElement = documented.get().getAnnotationType().asElement();
    expect.that(MoreElements.isType(annotationElement)).isTrue();
    expect.that(MoreElements.asType(annotationElement).getQualifiedName().toString()).isEqualTo(Documented.class.getCanonicalName());
    annotationElement = innerAnnotation.get().getAnnotationType().asElement();
    expect.that(MoreElements.isType(annotationElement)).isTrue();
    expect.that(MoreElements.asType(annotationElement).getQualifiedName().toString()).isEqualTo(InnerAnnotation.class.getCanonicalName());
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) Documented(java.lang.annotation.Documented) TypeElement(javax.lang.model.element.TypeElement) PackageElement(javax.lang.model.element.PackageElement) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) Test(org.junit.Test)

Example 3 with Documented

use of java.lang.annotation.Documented in project spring-loaded by spring-projects.

the class Play2 method doit.

public void doit() {
    Documented d = Foo.class.getAnnotation(Documented.class);
    System.out.println(d.annotationType());
}
Also used : Documented(java.lang.annotation.Documented)

Aggregations

Documented (java.lang.annotation.Documented)3 Method (java.lang.reflect.Method)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 PackageElement (javax.lang.model.element.PackageElement)1 TypeElement (javax.lang.model.element.TypeElement)1 Test (org.junit.Test)1