Java Code Examples for javax.lang.model.AnnotatedConstruct#getAnnotationMirrors()

The following examples show how to use javax.lang.model.AnnotatedConstruct#getAnnotationMirrors() . 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: TreeBackedAnnotationFactory.java    From buck with Apache License 2.0 6 votes vote down vote up
public static <A extends Annotation> A createOrGetUnderlying(
    TreeBackedAnnotatedConstruct annotatedConstruct,
    AnnotatedConstruct underlyingConstruct,
    Class<A> annotationType) {
  for (AnnotationMirror mirror : underlyingConstruct.getAnnotationMirrors()) {
    if (mirror.getAnnotationType().toString().equals(annotationType.getName()))
      return annotationType.cast(
          Proxy.newProxyInstance(
              annotationType.getClassLoader(),
              new Class[] {annotationType},
              new Handler(annotatedConstruct, annotationType, mirror)));
  }
  // Either the annotation doesn't exist or name comparison failed in some weird way.
  // Either way, fall back to the underlying construct.
  return annotatedConstruct.getAnnotationWithBetterErrors(annotationType);
}
 
Example 2
Source File: BasicAnnoTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 3
Source File: BasicAnnoTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 4
Source File: BasicAnnoTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 5
Source File: BasicAnnoTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 6
Source File: BasicAnnoTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 7
Source File: BasicAnnoTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 8
Source File: BasicAnnoTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}
 
Example 9
Source File: BasicAnnoTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get a specific annotation mirror from an annotated construct.
 */
static AnnotationMirror getAnnotation(AnnotatedConstruct e, String name) {
    for (AnnotationMirror m: e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            return m;
        }
    }
    return null;
}