Examples of AnnotationMirror


Examples of javax.lang.model.element.AnnotationMirror

   */
  private AnnotationMirror getConstraintMetaAnnotation(DeclaredType annotationType) {

    List<? extends AnnotationMirror> annotationMirrors = annotationType.asElement().getAnnotationMirrors();

    AnnotationMirror constraintMetaAnnotation = annotationApiHelper.getMirror(
        annotationMirrors, Constraint.class
    );

    if ( constraintMetaAnnotation == null ) {
      throw new IllegalArgumentException( "Given type " + annotationType + " isn't a constraint annotation type." );
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

  }

  @Override
  public Set<ConstraintCheckError> checkAnnotationType(TypeElement element, AnnotationMirror annotation) {

    AnnotationMirror constraintMirror = annotationApiHelper.getMirror(
        element.getAnnotationMirrors(), Constraint.class
    );
    boolean atLeastOneValidatorGiven = !annotationApiHelper.getAnnotationArrayValue(
        constraintMirror, "validatedBy"
    ).isEmpty();
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

   */
  public static AnnotationMirror getAnnotationMirror(Element element, String fqcn) {
    assert element != null;
    assert fqcn != null;

    AnnotationMirror mirror = null;
    for ( AnnotationMirror am : element.getAnnotationMirrors() ) {
      if ( isAnnotationMirrorOfType( am, fqcn ) ) {
        mirror = am;
        break;
      }
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

    List<? extends Element> myMembers = searchedElement.getEnclosedElements();
    for ( Element subElement : myMembers ) {
      List<? extends AnnotationMirror> entityAnnotations =
          context.getElementUtils().getAllAnnotationMirrors( subElement );
      for ( Object entityAnnotation : entityAnnotations ) {
        AnnotationMirror annotationMirror = (AnnotationMirror) entityAnnotation;
        if ( isIdAnnotation( annotationMirror ) ) {
          defaultAccessType = getAccessTypeOfIdAnnotation( subElement );
          break;
        }
      }
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

    return TypeUtils.isAnnotationMirrorOfType( annotationMirror, Id.class )
        || TypeUtils.isAnnotationMirrorOfType( annotationMirror, EmbeddedId.class );
  }

  public static AccessType determineAnnotationSpecifiedAccessType(Element element) {
    final AnnotationMirror accessAnnotationMirror = TypeUtils.getAnnotationMirror( element, Access.class );
    AccessType forcedAccessType = null;
    if ( accessAnnotationMirror != null ) {
      Element accessElement = (Element) TypeUtils.getAnnotationValue(
          accessAnnotationMirror,
          DEFAULT_ANNOTATION_PARAMETER_NAME
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

    log(annotations.toString());
    log(elements.toString());

    for (Element e : elements) {
      TypeElement providerImplementer = (TypeElement) e;
      AnnotationMirror providerAnnotation = getAnnotationMirror(e, ServiceProvider.class);
      DeclaredType providerInterface = getProviderInterface(providerAnnotation);
      TypeElement providerType = (TypeElement) providerInterface.asElement();

      log("provider interface: " + providerType.getQualifiedName());
      log("provider implementer: " + providerImplementer.getQualifiedName());
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

              valueConstraintValidatorMap);

          if (validator != null) {
            for (Element e : roundEnv
                .getElementsAnnotatedWith(annotationType)) {
              AnnotationMirror elementAnnotationMirror = AnnotationProcessingUtils
                  .findAnnotationMirror(processingEnv, e,
                      annotationType);
              Object actualValue = AnnotationProcessingUtils
                  .getAnnotationElementValue(
                      processingEnv,
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

  }

  private Class<?> getConstraintValidatorClass(
      TypeElement memberAnnotationTypeElement,
      Class<? extends Annotation> constraintAnnotationClass) {
    AnnotationMirror constraintAnnotation = AnnotationProcessingUtils
        .findAnnotationMirror(processingEnv,
            memberAnnotationTypeElement, constraintAnnotationClass);
    Class<?> constraintValidatorClass = null;

    if (constraintAnnotation != null) {
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

        }

        break;

      case ANNOTATION_TYPE:
        AnnotationMirror stereotypeAnnotationMirror = AnnotationProcessingUtils
            .findAnnotationMirror(procEnv, e,
                "javax.enterprise.inject.Stereotype");

        if (stereotypeAnnotationMirror == null) {
          procEnv.getMessager()
              .printMessage(
                  Diagnostic.Kind.ERROR,
                  "Annotation targets other than stereotyped annotation, enum, interface, class, constructor, field and methods are not supported",
                  e, annotation);
          break;
        }

        Set<Element> stereotypeAnnotatedElements = (Set<Element>) roundEnv
            .getElementsAnnotatedWith((TypeElement) e);

        for (Element stereotypeAnnotatedElement : stereotypeAnnotatedElements) {

          // Always add the element to the map, otherwise it won't be
          // validated
          elements.put(stereotypeAnnotatedElement,
              new HashSet<Element>());

          switch (stereotypeAnnotatedElement.getKind()) {
          case CONSTRUCTOR:
          case FIELD:
          case METHOD:
            for (Element classMemberElement : procEnv
                .getElementUtils()
                .getAllMembers(
                    (TypeElement) stereotypeAnnotatedElement
                        .getEnclosingElement())) {
              if (AnnotationProcessingUtils
                  .findAnnotationMirror(procEnv,
                      classMemberElement, annotationType) != null) {
                elements.get(stereotypeAnnotatedElement).add(
                    classMemberElement);
              }
            }

            break;
          case INTERFACE:
          case CLASS:
          case ENUM:
            for (Element classMemberElement : procEnv
                .getElementUtils()
                .getAllMembers(
                    (TypeElement) stereotypeAnnotatedElement)) {
              if (AnnotationProcessingUtils
                  .findAnnotationMirror(procEnv,
                      classMemberElement, annotationType) != null) {
                elements.get(stereotypeAnnotatedElement).add(
                    classMemberElement);
              }
            }

            break;
          default:
            procEnv.getMessager().printMessage(
                Diagnostic.Kind.ERROR,
                "Feature not yet implemented",
                stereotypeAnnotatedElement, annotation);
            break;
          }
        }

        break;
      default:
        procEnv.getMessager()
            .printMessage(
                Diagnostic.Kind.ERROR,
                "Annotation targets other than stereotyped annotation, enum, interface, class, constructor, field and methods are not supported",
                e, annotation);
        break;
      }
      break;
    case ELEMENT:
      elements.put(e, new HashSet<Element>(Arrays.asList(e)));
      break;
    }

    boolean unique;

    for (Map.Entry<Element, Set<Element>> elementEntry : elements
        .entrySet()) {
      unique = true;

      for (Element lookupElement : elementEntry.getValue()) {
        AnnotationMirror referencedAnnotationMirror = AnnotationProcessingUtils
            .findAnnotationMirror(lookupElement, annotationType);

        if (!e.equals(lookupElement)) {
          if (value
              .equals(AnnotationProcessingUtils
View Full Code Here

Examples of javax.lang.model.element.AnnotationMirror

          }
        }

        break;
      case ANNOTATION_TYPE:
        AnnotationMirror stereotypeAnnotationMirror = AnnotationProcessingUtils
            .findAnnotationMirror(procEnv, e,
                "javax.enterprise.inject.Stereotype");

        if (stereotypeAnnotationMirror == null) {
          procEnv.getMessager()
              .printMessage(
                  Diagnostic.Kind.ERROR,
                  "Annotation targets other than stereotyped annotation, enum, interface, class, constructor, field and methods are not supported",
                  e, annotation);
          break;
        }

        Set<Element> stereotypeAnnotatedElements = (Set<Element>) roundEnv
            .getElementsAnnotatedWith((TypeElement) e);

        for (Element stereotypeAnnotatedElement : stereotypeAnnotatedElements) {

          // Always add the element to the map, otherwise it won't be
          // validated
          elements.put(stereotypeAnnotatedElement,
              new HashSet<Element>());

          switch (stereotypeAnnotatedElement.getKind()) {
          case CONSTRUCTOR:
          case FIELD:
          case METHOD:
            for (Element classMemberElement : procEnv
                .getElementUtils()
                .getAllMembers(
                    (TypeElement) stereotypeAnnotatedElement
                        .getEnclosingElement())) {
              if (AnnotationProcessingUtils.findAnnotationMirror(
                  procEnv, classMemberElement,
                  referencedAnnotationTypeElement) != null) {
                elements.get(stereotypeAnnotatedElement).add(
                    classMemberElement);
              }
            }

            break;
          case INTERFACE:
          case CLASS:
            // Maybe add here support for subtype checking, so that
            // abstract classes or interfaces must not explicitly
            // fullfill a
            // referencing constraint, but also a subtype can do
          case ENUM:
            for (Element classMemberElement : procEnv
                .getElementUtils()
                .getAllMembers(
                    (TypeElement) stereotypeAnnotatedElement)) {
              if (AnnotationProcessingUtils.findAnnotationMirror(
                  procEnv, classMemberElement,
                  referencedAnnotationTypeElement) != null) {
                elements.get(stereotypeAnnotatedElement).add(
                    classMemberElement);
              }
            }

            break;
          default:
            procEnv.getMessager().printMessage(
                Diagnostic.Kind.ERROR,
                "Feature not yet implemented",
                stereotypeAnnotatedElement, annotation);
            break;
          }
        }

        break;
      default:
        procEnv.getMessager()
            .printMessage(
                Diagnostic.Kind.ERROR,
                "Annotation targets other than stereotyped annotation, enum, interface, class, constructor, field and methods are not supported",
                e, annotation);
        break;
      }
      break;
    case ELEMENT:
      if (AnnotationProcessingUtils.findAnnotationMirror(procEnv, e,
          referencedAnnotationTypeElement) != null) {
        elements.put(e, new HashSet<Element>(Arrays.asList(e)));
      }

      break;
    }

    OUTER: for (Map.Entry<Element, Set<Element>> elementEntry : elements
        .entrySet()) {
      for (Element lookupElement : elementEntry.getValue()) {
        AnnotationMirror referencedAnnotationMirror = AnnotationProcessingUtils
            .findAnnotationMirror(procEnv, lookupElement,
                referencedAnnotationTypeElement);
        Object memberName = null;

        // Should never be null here
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.