javax.annotation.ParametersAreNonnullByDefault#java.lang.annotation.Documented源码实例Demo

下面列出了javax.annotation.ParametersAreNonnullByDefault#java.lang.annotation.Documented 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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));
}
 
源代码2 项目: TencentKona-8   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
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));
}
 
源代码4 项目: jdk8u60   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
源代码5 项目: openjdk-jdk8u   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
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);
        }
    }
}
 
源代码7 项目: openjdk-jdk9   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
源代码8 项目: hottub   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
源代码9 项目: openjdk-8-source   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
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));
}
 
源代码11 项目: openjdk-8   文件: NoPrivateTypesExported.java
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);
        }
    }
}
 
源代码12 项目: dolphin-platform   文件: ClasspathScannerTest.java
@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));
}
 
源代码13 项目: auto   文件: MoreElementsTest.java
@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());
}
 
@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));
}
 
@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));
}
 
@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));
}
 
源代码17 项目: openjdk-jdk9   文件: Utils.java
/**
 * 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;
}
 
源代码18 项目: openjdk-jdk9   文件: Utils.java
/**
 * 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;
}
 
源代码19 项目: jshERP   文件: AnnotationUtils.java
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;
}
 
源代码20 项目: dolphin-platform   文件: ClasspathScannerTest.java
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);
}
 
源代码21 项目: auto   文件: MoreElementsTest.java
@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();
}
 
源代码22 项目: cxf   文件: CdiResourceProviderTest.java
@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();
}