Package javax.lang.model.element

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


  }

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

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

  }

  private Set<TypeMirror> getSupportedTypesForCustomConstraint(DeclaredType constraintAnnotationType) {

    //the Constraint meta-annotation at the type declaration, e.g. "@Constraint(validatedBy = CheckCaseValidator.class)"
    AnnotationMirror constraintMetaAnnotation = getConstraintMetaAnnotation( constraintAnnotationType );

    //the validator classes, e.g. [CheckCaseValidator.class]
    List<? extends AnnotationValue> validatorClassReferences = getValidatorClassesFromConstraintMetaAnnotation(
        constraintMetaAnnotation
    );
View Full Code Here

   */
  private AnnotationMirror getConstraintMetaAnnotation(DeclaredType annotationType) {

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

    AnnotationMirror constraintMetaAnnotation = annotationApiHelper.getMirror(
        annotationMirrors, BeanValidationTypes.CONSTRAINT
    );

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

  }

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

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

      Element element = processingContext.get(key.element);
      if (element == null) {
        delta.add(new AnnotationChange(key, entry.getValue(), null));
        processingContext.log(Level.FINER, "Annotation removed " + key);
      } else {
        AnnotationMirror found = null;
        for (AnnotationMirror mirror : element.getAnnotationMirrors()) {
          Name f = Name.parse(((TypeElement)mirror.getAnnotationType().asElement()).getQualifiedName().toString());
          if (key.getType().equals(f)) {
            found = mirror;
            break;
View Full Code Here

  @Override
  public void init(ApplicationMetaModel application) {
    ControllersMetaModel controllers = new ControllersMetaModel(this);
    PackageElement pkg = application.model.processingContext.get(application.getHandle());
    AnnotationMirror annotation = Tools.getAnnotation(pkg, Application.class.getName());
    AnnotationState values = AnnotationState.create(annotation);
    Boolean escapeXML = (Boolean)values.get("escapeXML");
    ElementHandle.Type defaultControllerElt = (ElementHandle.Type)values.get("defaultController");
    ElementHandle.Type errorControllerElt = (ElementHandle.Type)values.get("errorController");
    controllers.escapeXML = escapeXML;
View Full Code Here

      PackageElement pkgElt = env.get(pkgHandle);
      Boolean minify = (Boolean)annotation.get("minify");
      List<String> resources = (List<String>)annotation.get("value");

      // WARNING THIS IS NOT CORRECT BUT WORK FOR NOW
      AnnotationMirror annotationMirror = Tools.getAnnotation(pkgElt, Less.class.getName());

      //
      log.info("Handling less annotation for package " + pkg + ": minify=" + minify + " resources=" + resources);

      //
View Full Code Here

        @Override
        protected void doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
          if (count.getAndIncrement() == 0) {
            ElementHandle.Field index = ElementHandle.Field.create("plugin.template.completion.A", "index");
            VariableElement indexElt = index.get(processingEnv);
            AnnotationMirror pathAnn = indexElt.getAnnotationMirrors().get(0);
            TypeElement annotationTypeElement = (TypeElement)pathAnn.getAnnotationType().asElement();
            ExecutableElement value = (ExecutableElement)annotationTypeElement.getEnclosedElements().get(0);
            for (Completion completion : getCompletions(indexElt, pathAnn, value, test[0])) {
              completions.add(completion.getValue());
            }
          }
View Full Code Here

    }
    catch (Exception e) {
      if (e instanceof ProcessingException) {
        ProcessingException ce = (ProcessingException)e;
        Element element = ce.getElement();
        AnnotationMirror annotation = ce.getAnnotation();

        //
        StringBuilder msg = new StringBuilder();

        for (Message cm : ce) {
          msg.setLength(0);
          MessageCode code = cm.getCode();
          String[] args = cm.getArguments();
          if (formalErrorReporting) {
            cm.format(msg, true);
          }
          else {
            try {
              new Formatter(msg).format(Locale.getDefault(), code.getMessage(), (Object[])args).flush();
            }
            catch (Exception e1) {
              e1.printStackTrace();
              System.out.println("---------------------------------------");
              System.out.println(code.getMessage());
              System.out.println(Arrays.toString(args));
              e.printStackTrace();
              System.out.println("---------------------------------------");
            }
          }

          // Log error
          StringWriter writer = new StringWriter();
          if (element == null) {
            writer.append("Compilation error: ");
          }
          else if (annotation == null) {
            writer.
              append("Compilation error for element ").
              append(element.toString()).append(": ");
          }
          else {
            writer.
              append("Compilation error for element ").
              append(element.toString()).
              append(" at annotation ").
              append(annotation.toString()).append(": ");
          }
          writer.append(msg).append("\n");
          e.printStackTrace(new PrintWriter(writer));
          logger.info(writer.getBuffer());
View Full Code Here

TOP

Related Classes of javax.lang.model.element.AnnotationMirror

Copyright © 2018 www.massapicom. 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.