java.lang.annotation.Documented Java Examples

The following examples show how to use java.lang.annotation.Documented. 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 Project: spring-analysis-note   Author: Vip-Augus   File: AnnotationMetadataTests.java    License: MIT License 6 votes vote down vote up
private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
	assertThat(metadata.getClassName(), is(Component.class.getName()));
	assertThat(metadata.isInterface(), is(true));
	assertThat(metadata.isAnnotation(), is(true));
	assertThat(metadata.isAbstract(), is(true));
	assertThat(metadata.isConcrete(), is(false));
	assertThat(metadata.hasSuperClass(), is(false));
	assertThat(metadata.getSuperClassName(), nullValue());
	assertThat(metadata.getInterfaceNames().length, is(1));
	assertThat(metadata.getInterfaceNames()[0], is(Annotation.class.getName()));
	assertThat(metadata.isAnnotated(Documented.class.getName()), is(false));
	assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
	assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Documented.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.getAnnotationTypes().size(), is(1));
}
 
Example #2
Source Project: TencentKona-8   Author: Tencent   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #3
Source Project: java-technology-stack   Author: codeEngraver   File: AnnotationMetadataTests.java    License: MIT License 6 votes vote down vote up
private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
	assertThat(metadata.getClassName(), is(Component.class.getName()));
	assertThat(metadata.isInterface(), is(true));
	assertThat(metadata.isAnnotation(), is(true));
	assertThat(metadata.isAbstract(), is(true));
	assertThat(metadata.isConcrete(), is(false));
	assertThat(metadata.hasSuperClass(), is(false));
	assertThat(metadata.getSuperClassName(), nullValue());
	assertThat(metadata.getInterfaceNames().length, is(1));
	assertThat(metadata.getInterfaceNames()[0], is(Annotation.class.getName()));
	assertThat(metadata.isAnnotated(Documented.class.getName()), is(false));
	assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
	assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Documented.class.getName()), is(true));
	assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.getAnnotationTypes().size(), is(4));
}
 
Example #4
Source Project: jdk8u60   Author: chenghanpeng   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #5
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #6
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #7
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #8
Source Project: hottub   Author: dsrg-uoft   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #9
Source Project: openjdk-8-source   Author: keerath   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #10
Source Project: spring4-understanding   Author: langtianya   File: AnnotationMetadataTests.java    License: Apache License 2.0 6 votes vote down vote up
private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
	assertThat(metadata.getClassName(), is(Component.class.getName()));
	assertThat(metadata.isInterface(), is(true));
	assertThat(metadata.isAnnotation(), is(true));
	assertThat(metadata.isAbstract(), is(true));
	assertThat(metadata.isConcrete(), is(false));
	assertThat(metadata.hasSuperClass(), is(false));
	assertThat(metadata.getSuperClassName(), nullValue());
	assertThat(metadata.getInterfaceNames().length, is(1));
	assertThat(metadata.getInterfaceNames()[0], is(Annotation.class.getName()));
	assertThat(metadata.isAnnotated(Documented.class.getName()), is(false));
	assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
	assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(Documented.class.getName()), is(true));
	assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
	assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
	assertThat(metadata.getAnnotationTypes().size(), is(3));
}
 
Example #11
Source Project: openjdk-8   Author: bpupadhyaya   File: NoPrivateTypesExported.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
                               Set<String> acceptable) {
    for (AnnotationMirror mirror : annotations) {
        Element annotationElement = mirror.getAnnotationType().asElement();

        if (annotationElement.getAnnotation(Documented.class) == null) {
            note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
        }

        verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);

        for (AnnotationValue value : mirror.getElementValues().values()) {
            verifyAnnotationValue(value, acceptable);
        }
    }
}
 
Example #12
Source Project: dolphin-platform   Author: canoo   File: ClasspathScannerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testScanOtherPackage() {
    //There can't be a class that is annotated with Inject
    final DefaultClasspathScanner scanner = new DefaultClasspathScanner(CLASSPATH_SCAN);
    Set<Class<?>> classes = scanner.getTypesAnnotatedWith(Resources.class);
    assertNotNull(classes);
    assertEquals(classes.size(), 0);

    classes = scanner.getTypesAnnotatedWith(AnnotationForClasspathScanTest.class);
    assertNotNull(classes);
    assertEquals(classes.size(), 0);

    classes = scanner.getTypesAnnotatedWith(Documented.class);
    assertNotNull(classes);
    assertEquals(classes.size(), 1);
    assertTrue(classes.contains(DocumentAnnotatedClass.class));
}
 
Example #13
Source Project: auto   Author: google   File: MoreElementsTest.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #14
Source Project: spring-analysis-note   Author: Vip-Augus   File: AnnotationUtilsTests.java    License: MIT License 5 votes vote down vote up
@Test
public void isAnnotationMetaPresentForPlainType() {
	assertTrue(isAnnotationMetaPresent(Order.class, Documented.class));
	assertTrue(isAnnotationMetaPresent(NonNullApi.class, Documented.class));
	assertTrue(isAnnotationMetaPresent(NonNullApi.class, Nonnull.class));
	assertTrue(isAnnotationMetaPresent(ParametersAreNonnullByDefault.class, Nonnull.class));
}
 
Example #15
Source Project: spring-analysis-note   Author: Vip-Augus   File: AnnotatedElementUtilsTests.java    License: MIT License 5 votes vote down vote up
@Test
public void isAnnotatedForPlainTypes() {
	assertTrue(isAnnotated(Order.class, Documented.class));
	assertTrue(isAnnotated(NonNullApi.class, Documented.class));
	assertTrue(isAnnotated(NonNullApi.class, Nonnull.class));
	assertTrue(isAnnotated(ParametersAreNonnullByDefault.class, Nonnull.class));
}
 
Example #16
Source Project: spring-analysis-note   Author: Vip-Augus   File: AnnotatedElementUtilsTests.java    License: MIT License 5 votes vote down vote up
@Test
public void hasAnnotationForPlainTypes() {
	assertTrue(hasAnnotation(Order.class, Documented.class));
	assertTrue(hasAnnotation(NonNullApi.class, Documented.class));
	assertTrue(hasAnnotation(NonNullApi.class, Nonnull.class));
	assertTrue(hasAnnotation(ParametersAreNonnullByDefault.class, Nonnull.class));
}
 
Example #17
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Utils.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given an annotation, return true if it should be documented and false
 * otherwise.
 *
 * @param annotation the annotation to check.
 *
 * @return true return true if it should be documented and false otherwise.
 */
public boolean isDocumentedAnnotation(TypeElement annotation) {
    for (AnnotationMirror anno : annotation.getAnnotationMirrors()) {
        if (getFullyQualifiedName(anno.getAnnotationType().asElement()).equals(
                Documented.class.getName())) {
            return true;
        }
    }
    return false;
}
 
Example #18
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Utils.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given an annotation, return true if it should be documented and false
 * otherwise.
 *
 * @param annotationDoc the annotation to check.
 *
 * @return true return true if it should be documented and false otherwise.
 */
public boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) {
    for (AnnotationDesc anno : annotationDoc.annotations()) {
        if (anno.annotationType().qualifiedName().equals(
                Documented.class.getName())) {
            return true;
        }
    }
    return false;
}
 
Example #19
Source Project: jshERP   Author: jishenghua   File: AnnotationUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static <A extends Annotation> A getAnnotation(Class<?> cls, Class<A> annotationClass) {
    A res = cls.getAnnotation(annotationClass);
    if (res == null) {
        for (Annotation annotation : cls.getAnnotations()) {
            if (annotation instanceof Documented) {
                break;
            }
            res = getAnnotation(annotation.annotationType(), annotationClass);
            if (res != null)
                break;
        }
    }
    return res;
}
 
Example #20
Source Project: dolphin-platform   Author: canoo   File: ClasspathScannerTest.java    License: Apache License 2.0 5 votes vote down vote up
private void assertForAnnotation(final DefaultClasspathScanner scanner) {
    final Set<Class<?>> resourceClasses = scanner.getTypesAnnotatedWith(Resource.class);
    assertNotNull(resourceClasses);
    assertEquals(resourceClasses.size(), 1);

    final Set<Class<?>> documentClasses = scanner.getTypesAnnotatedWith(Documented.class);
    assertNotNull(documentClasses);
    assertEquals(documentClasses.size(), 1);
}
 
Example #21
Source Project: auto   Author: google   File: MoreElementsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void isAnnotationPresent() {
  TypeElement annotatedAnnotationElement =
      compilation.getElements().getTypeElement(AnnotatedAnnotation.class.getCanonicalName());
  assertThat(MoreElements.isAnnotationPresent(annotatedAnnotationElement, Documented.class))
      .isTrue();
  assertThat(MoreElements.isAnnotationPresent(annotatedAnnotationElement, InnerAnnotation.class))
      .isTrue();
  assertThat(MoreElements.isAnnotationPresent(annotatedAnnotationElement, SuppressWarnings.class))
      .isFalse();
}
 
Example #22
Source Project: cxf   Author: apache   File: CdiResourceProviderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void perRequest() {
    // not a scope so will be considered as a not singleton bean
    when(bean.getScope()).thenReturn(Class.class.cast(Documented.class));
    assertNotSingleton();
}