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 File: NoPrivateTypesExported.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #2
Source File: MoreElementsTest.java From auto with Apache License 2.0 | 6 votes |
@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 #3
Source File: ClasspathScannerTest.java From dolphin-platform with Apache License 2.0 | 6 votes |
@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 #4
Source File: NoPrivateTypesExported.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 File: AnnotationMetadataTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
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 #6
Source File: NoPrivateTypesExported.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 File: NoPrivateTypesExported.java From hottub with GNU General Public License v2.0 | 6 votes |
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 File: NoPrivateTypesExported.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 File: NoPrivateTypesExported.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 File: NoPrivateTypesExported.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: AnnotationMetadataTests.java From java-technology-stack with MIT License | 6 votes |
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 #12
Source File: NoPrivateTypesExported.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #13
Source File: AnnotationMetadataTests.java From spring-analysis-note with MIT License | 6 votes |
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 #14
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 #15
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 #16
Source File: AnnotationUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@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 #17
Source File: AnnotationUtils.java From jshERP with GNU General Public License v3.0 | 5 votes |
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 #18
Source File: ClasspathScannerTest.java From dolphin-platform with Apache License 2.0 | 5 votes |
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 #19
Source File: AnnotatedElementUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@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 #20
Source File: MoreElementsTest.java From auto with Apache License 2.0 | 5 votes |
@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 #21
Source File: AnnotatedElementUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@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 #22
Source File: CdiResourceProviderTest.java From cxf with Apache License 2.0 | 4 votes |
@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(); }