private ImmutableMap<String, String> extractPlaceholderValues( AnnotationMirror annotation, Environment environment) { ImmutableMap.Builder<String, String> literals = ImmutableMap.builder(); for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : environment.processing() .getElementUtils() .getElementValuesWithDefaults(CachingElements.getDelegate(annotation)) .entrySet()) { String key = e.getKey().getSimpleName().toString(); String value = AnnotationMirrors.toCharSequence(e.getValue()).toString(); literals.put(key, value); } return literals.build(); }
@Override public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv ) { for ( TypeElement type : annotations ) { for ( Element annotated : roundEnv.getElementsAnnotatedWith( type ) ) { for ( AnnotationMirror mirror : annotated.getAnnotationMirrors() ) { if ( mirror.getAnnotationType().asElement().equals( type ) ) { try { process( type, annotated, mirror, processingEnv.getElementUtils() .getElementValuesWithDefaults( mirror ) ); } catch ( Exception e ) { e.printStackTrace(); processingEnv.getMessager().printMessage( Kind.ERROR, "Internal error: " + e, annotated, mirror ); } } } } } return false; }
elements.getElementValuesWithDefaults(mirror).entrySet()) { if (parameterName.equals(entry.getKey().getSimpleName().toString())) { try {
/** * Returns the annotation value of the given annotation mirror with the * given name or its default value if it was not specified. * * @param annotationMirror An annotation mirror. * @param name The name of the annotation value of interest. * * @return The annotation value with the given name or it's default value or null, if one of the * input values is null or if no value with the given name exists * within the given annotation mirror. */ public AnnotationValue getAnnotationValueOrDefault(AnnotationMirror annotationMirror, String name) { if ( annotationMirror == null || name == null ) { return null; } Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = elementUtils.getElementValuesWithDefaults( annotationMirror ); for ( Entry<? extends ExecutableElement, ? extends AnnotationValue> oneElementValue : elementValues.entrySet() ) { if ( oneElementValue.getKey().getSimpleName().contentEquals( name ) ) { return oneElementValue.getValue(); } } return null; }
Map <? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults (final AnnotationMirror annotation) { return m_aElementUtils.getElementValuesWithDefaults (annotation); } }
@Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults( AnnotationMirror a) { return elements.getElementValuesWithDefaults(a); }
private Integer getPriority(final Elements elements, final AnnotationMirror mirror, final ExecutableElement priorityFor) { if (priorityFor == null) { return null; // *Default annos } return (Integer)elements.getElementValuesWithDefaults(mirror) .get(priorityFor) .getValue(); }
public AnnotationWrapper(MapperGeneratorContext context, AnnotationMirror annotationMirror, Element annotatedElement) { this.annotationMirror = annotationMirror; this.annotatedElement = annotatedElement; this.map = new HashMap<String, AnnotationValue>(); this.context = context; for (ExecutableElement executableElement : context.elements.getElementValuesWithDefaults(annotationMirror).keySet()) { this.map.put(executableElement.getSimpleName().toString(), context.elements.getElementValuesWithDefaults(annotationMirror).get(executableElement)); } }
public static AnnotationValue extractAnnotationPropertyValue(final Elements elementUtils, final AnnotationMirror annotation, final CharSequence annotationProperty) { final Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParams = elementUtils .getElementValuesWithDefaults(annotation); for (final Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> param : annotationParams.entrySet()) { if (param.getKey().getSimpleName().contentEquals(annotationProperty)) { return param.getValue(); } } return null; }
public static AnnotationValue extractAnnotationPropertyValue(Elements elementUtils, AnnotationMirror annotation, CharSequence annotationProperty) { Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParams = elementUtils.getElementValuesWithDefaults(annotation); for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> param : annotationParams.entrySet()) { if (param.getKey().getSimpleName().contentEquals(annotationProperty)) { return param.getValue(); } } return null; }
public static AnnotationValue extractAnnotationPropertyValue(Elements elementUtils, AnnotationMirror annotation, CharSequence annotationProperty) { Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParams = elementUtils.getElementValuesWithDefaults(annotation); for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> param : annotationParams.entrySet()) { if (param.getKey().getSimpleName().contentEquals(annotationProperty)) { return param.getValue(); } } return null; }
public Map<String,Object> getAnnotationValues(AnnotationMirror mirror) { Map<? extends ExecutableElement,? extends AnnotationValue> values = elements.getElementValuesWithDefaults(mirror); Map<String,Object> result = new HashMap<>(); for(Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : values.entrySet()) { ExecutableElement key = entry.getKey(); AnnotationValue val = entry.getValue(); result.put(key.getSimpleName().toString(), val.getValue()); } return result; }
public Object getValue(String annotationAttributeName) { for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : processingEnv.getElementUtils().getElementValuesWithDefaults(mirror).entrySet()) { if (entry.getKey().getSimpleName().toString().equals(annotationAttributeName)) { return entry.getValue().getValue(); } } return null; }
@Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults(AnnotationMirror a) { while (a instanceof DecoratedAnnotationMirror) { a = ((DecoratedAnnotationMirror)a).getDelegate(); } return delegate.getElementValuesWithDefaults(a); }
private BiFunction<Element, AnnotationMirror, String[]> useDefaultClass(ExecutableElement annotatedMethod, MethodRef mr) { String className = getAnnotationClassValue(elements, mr, MethodRef::defaultClass).toString(); return (e, am) -> new String[] { className, elements.getElementValuesWithDefaults(am).get(annotatedMethod).getValue().toString() }; }
private BiFunction<Element, AnnotationMirror, String[]> useDefaultClass(ExecutableElement annotatedMethod, MethodRef mr) { String className = getAnnotationClassValue(elements, mr, MethodRef::defaultClass).toString(); return (e, am) -> new String[] { className, elements.getElementValuesWithDefaults(am).get(annotatedMethod).getValue().toString() }; }
@Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValuesWithDefaults(AnnotationMirror a) { while (a instanceof DecoratedAnnotationMirror) { a = ((DecoratedAnnotationMirror)a).getDelegate(); } return delegate.getElementValuesWithDefaults(a); }
/** * Returns the annotation values mapped from their name for all methods of the given annotation mirror. */ @Pure public static @Nonnull Map<@Nonnull String, @Nonnull AnnotationValue> getAnnotationValues(@Nonnull AnnotationMirror annotationMirror) { final @Nonnull Map<@Nonnull String, @Nonnull AnnotationValue> result = new HashMap<>(); for (Map.@Nonnull Entry<@Nonnull ? extends ExecutableElement, @Nonnull ? extends AnnotationValue> annotationEntry : StaticProcessingEnvironment.getElementUtils().getElementValuesWithDefaults(annotationMirror).entrySet()) { result.put(annotationEntry.getKey().getSimpleName().toString(), annotationEntry.getValue()); } return result; }
public AnnotationValueInfo processAnnotation(AnnotationMirror annotation) { String fqn = ((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName().toString(); AnnotationValueInfo owner = new AnnotationValueInfo(fqn); Map<? extends ExecutableElement, ? extends AnnotationValue> valueMap = elementUtils.getElementValuesWithDefaults(annotation); for (ExecutableElement valueElt : valueMap.keySet().stream().filter(e -> e.getKind().equals(ElementKind.METHOD)).collect(Collectors.toSet())) { owner.putMember(valueElt.getSimpleName().toString(), processAnnotationMemberValue(valueMap.get(valueElt))); } return owner; }
private BiFunction<Element, AnnotationMirror, String[]> useAll(ExecutableElement annotatedMethod, MethodRef mr) { char splitor = mr.splitor(); return (e, am) -> { AnnotationValue av = elements.getElementValuesWithDefaults(am).get(annotatedMethod); String value = av.getValue().toString(); String[] split = value.split(Pattern.quote(Character.toString(splitor))); assertThat(split.length == 2) .todo(() -> error().log("The method reference must be $ClassName" + splitor + "$MethodName", e, am, av)); return split; }; }