Package javax.lang.model.element

Examples of javax.lang.model.element.AnnotationValue


   *         such value exists within the given annotation mirror or such a
   *         value exists but is not an array-typed one.
   */
  public List<? extends AnnotationValue> getAnnotationArrayValue(AnnotationMirror annotationMirror, String name) {

    AnnotationValue annotationValue = getAnnotationValue( annotationMirror, name );

    if ( annotationValue == null ) {
      return Collections.<AnnotationValue>emptyList();
    }

    List<? extends AnnotationValue> theValue = annotationValue.accept(
        new SimpleAnnotationValueVisitor6<List<? extends AnnotationValue>, Void>() {

          @Override
          public List<? extends AnnotationValue> visitArray(List<? extends AnnotationValue> values, Void p) {
            return values;
View Full Code Here


    return constraintMetaAnnotation;
  }

  private List<? extends AnnotationValue> getValidatorClassesFromConstraintMetaAnnotation(AnnotationMirror constraintMetaAnnotation) {

    AnnotationValue validatedBy = annotationApiHelper.getAnnotationValue( constraintMetaAnnotation, "validatedBy" );

    return validatedBy.accept(
        new SimpleAnnotationValueVisitor6<List<? extends AnnotationValue>, Void>() {

          @Override
          public List<? extends AnnotationValue> visitArray(List<? extends AnnotationValue> values, Void p) {
            return values;
View Full Code Here

        // Process the values.
        Set<? extends ExecutableElement> keys = annotationMirror.getElementValues().keySet();
       
        for (ExecutableElement annotationElement : keys) {
            AnnotationValue annotationValue = annotationMirror.getElementValues().get(annotationElement);
            String attribute = annotationElement.getSimpleName().toString();
            Object attributeValue = annotationValue.accept(this, arg1);
            annotation.addAttribute(attribute, attributeValue);
        }

        return annotation;
    }
View Full Code Here

      if (method == null) {
        // ideally we should be able to create a fake ExecutableElementImpl
        continue;
      }
      ExecutableElement e = new ExecutableElementImpl(_env, method);
      AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method);
      valueMap.put(e, v);
    }
    return Collections.unmodifiableMap(valueMap);
  }
View Full Code Here

      boolean foundExplicitValue = false;
      for (int i = 0; i < pairs.length; ++i) {
        MethodBinding explicitBinding = pairs[i].getMethodBinding();
        if (method == explicitBinding) {
          ExecutableElement e = new ExecutableElementImpl(_env, explicitBinding);
          AnnotationValue v = new AnnotationMemberValue(_env, pairs[i].getValue(), explicitBinding);
          valueMap.put(e, v);
          foundExplicitValue = true;
          break;
        }
      }
      // else get default value if one exists
      if (!foundExplicitValue) {
        Object defaultVal = method.getDefaultValue();
        if (null != defaultVal) {
          ExecutableElement e = new ExecutableElementImpl(_env, method);
          AnnotationValue v = new AnnotationMemberValue(_env, defaultVal, method);
          valueMap.put(e, v);
        }
      }
    }
    return Collections.unmodifiableMap(valueMap);
View Full Code Here

      if (method == null) {
        // ideally we should be able to create a fake ExecutableElementImpl
        continue;
      }
      ExecutableElement e = new ExecutableElementImpl(_env, method);
      AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method);
      valueMap.put(e, v);
    }
    return Collections.unmodifiableMap(valueMap);
  }
View Full Code Here

      boolean foundExplicitValue = false;
      for (int i = 0; i < pairs.length; ++i) {
        MethodBinding explicitBinding = pairs[i].getMethodBinding();
        if (method == explicitBinding) {
          ExecutableElement e = new ExecutableElementImpl(_env, explicitBinding);
          AnnotationValue v = new AnnotationMemberValue(_env, pairs[i].getValue(), explicitBinding);
          valueMap.put(e, v);
          foundExplicitValue = true;
          break;
        }
      }
      // else get default value if one exists
      if (!foundExplicitValue) {
        Object defaultVal = method.getDefaultValue();
        if (null != defaultVal) {
          ExecutableElement e = new ExecutableElementImpl(_env, method);
          AnnotationValue v = new AnnotationMemberValue(_env, defaultVal, method);
          valueMap.put(e, v);
        }
      }
    }
    return Collections.unmodifiableMap(valueMap);
View Full Code Here

        // Process the values.
        Set<? extends ExecutableElement> keys = annotationMirror.getElementValues().keySet();
       
        for (ExecutableElement annotationElement : keys) {
            AnnotationValue annotationValue = annotationMirror.getElementValues().get(annotationElement);
            String attribute = annotationElement.getSimpleName().toString();
            Object attributeValue = annotationValue.accept(this, arg1);
            annotation.addAttribute(attribute, attributeValue);
        }

        return annotation;
    }
View Full Code Here

   *         the parameter is not present on the annotation.
   */
  public static String extractAnnotationStringValue(Elements elementUtils, AnnotationMirror annotation,
          CharSequence paramName) {

    final AnnotationValue av = extractAnnotationPropertyValue(elementUtils, annotation, paramName);
    if (av != null && av.getValue() != null) {
      return av.getValue().toString();
    }

    return null;
  }
View Full Code Here

        for (final Object word : args) {
            assertTrue(msg.contains(word.toString()));
        }

        AnnotationValue aValue = null;
        msg = msgs.format(Kind.ERROR, note, ele, aMirror, aValue, args);

        for (final Object word : args) {
            assertTrue(msg.contains(word.toString()));
        }
View Full Code Here

TOP

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

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.