@Override public Builder visitArray(List<? extends AnnotationValue> values, String name) { for (AnnotationValue value : values) { value.accept(this, name); } return builder; } }
@Override public Void visitArray(List<? extends AnnotationValue> list, Void unused) { for (AnnotationValue value : list) { value.accept(this, null); } return null; } },
/** * Returns the list of values represented by an array annotation value. * * @throws IllegalArgumentException unless {@code annotationValue} represents an array */ static ImmutableList<AnnotationValue> asAnnotationValues( AnnotationValue annotationValue) { return annotationValue.accept(AS_ANNOTATION_VALUES, null); }
@Override public Void visitArray(List<? extends AnnotationValue> vals, Void p) { for (AnnotationValue annotationValue : vals) { annotationValue.accept(this, p); } return null; }
void visitValue(AnnotationValue value) { value.accept(this, null); }
@Override public Object visitArray(List<? extends AnnotationValue> values, Void v) { Object[] result = new Object[values.size()]; for (int i = 0; i < values.size(); i++) { result[i] = values.get(i).accept(this, null); } return result; } };
@Override public Stream<String> visitArray(List<? extends AnnotationValue> list, Void aVoid) { return list.stream().flatMap(a -> a.accept(this, null)).filter(x -> x != null); } },
@Override public Stream<String> visitArray(List<? extends AnnotationValue> list, Void unused) { return list.stream().flatMap(a -> a.accept(this, null)).filter(x -> x != null); } },
@Override public Void visitArray(List<? extends AnnotationValue> vals, Void aVoid) { vals.stream().forEachOrdered(v -> v.accept(this, null)); return super.visitArray(vals, aVoid); } },
public static AnnotationSpec get(AnnotationMirror annotation) { TypeElement element = (TypeElement) annotation.getAnnotationType().asElement(); AnnotationSpec.Builder builder = AnnotationSpec.builder(ClassName.get(element)); Visitor visitor = new Visitor(builder); for (ExecutableElement executableElement : annotation.getElementValues().keySet()) { String name = executableElement.getSimpleName().toString(); AnnotationValue value = annotation.getElementValues().get(executableElement); value.accept(visitor, name); } return builder.build(); }
public void copyAnnotation(IJAnnotatable annotatable, AnnotationMirror annotationMirror) { Map<? extends ExecutableElement, ? extends AnnotationValue> parameters = annotationMirror.getElementValues(); if (!hasAnnotation(annotatable, annotationMirror) || annotatable instanceof JAnnotationArrayMember) { AbstractJClass annotation = typeMirrorToJClass(annotationMirror.getAnnotationType()); JAnnotationUse annotate = annotatable.annotate(annotation); for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> param : parameters.entrySet()) { param.getValue().accept(new AnnotationParamExtractor(annotate, this), param.getKey().getSimpleName().toString()); } } }
@Override public Void visitArray(List<? extends AnnotationValue> vals, String p) { JAnnotationArrayMember paramArray = use.paramArray(p); for (AnnotationValue annotationValue : vals) { annotationValue.accept(new AnnotationArrayParamExtractor(helper), paramArray); } return null; }
private static void collectTypesFromAnnotationAttribute( String annotationValueName, final ImmutableCollection.Builder<TypeMirror> builder, AnnotationMirror annotationMirror) { for (Entry<? extends ExecutableElement, ? extends AnnotationValue> e : annotationMirror .getElementValues() .entrySet()) { if (e.getKey().getSimpleName().contentEquals(annotationValueName)) { e.getValue().accept(new SimpleAnnotationValueVisitor7<Void, Void>() { @Override public Void visitArray(List<? extends AnnotationValue> vals, Void p) { for (AnnotationValue annotationValue : vals) { annotationValue.accept(this, p); } return null; } @Override public Void visitType(TypeMirror t, Void p) { builder.add(t); return null; } }, null); } } }
: annotation.getElementValues().entrySet()) { String name = e.getKey().getSimpleName().toString(); Object value = e.getValue().accept(VALUE_EXTRACTOR, null); Object defaultValue = result.get(name); if (!lenientIsInstance(defaultValue.getClass(), value)) {
StringResource(String name, Collection<AnnotationSpec> annotations, Collection<ClassName> markers, AnnotationValue defaultValue, String javadoc) { super((name.startsWith(Strings.PREFIX_RES)) ? WordUtils.uncapitalize(name.substring(Strings.PREFIX_RES.length())) : name, Types.STRING, annotations, javadoc, markers, defaultValue); this.originalName = name; this.hasDefault = defaultValue != null && getDefaultValue().accept(new IsValidResourceVisitor(), null); getAnnotations().remove(Types.STRING_RES); getAnnotations().add(hasDefault ? Types.NON_NULL : Types.NULLABLE); }
@NonNull @Override public CodeBlock visitArray(@NonNull List<? extends AnnotationValue> values, Void v) { ArrayTypeName arrayTypeName = (ArrayTypeName) type; if (arrayTypeName.componentType instanceof ParameterizedTypeName) { arrayTypeName = ArrayTypeName.of(((ParameterizedTypeName) arrayTypeName.componentType).rawType); } return CodeBlock.of("new $T{$L}", arrayTypeName, values.stream().map(value -> value.accept(this, null)) .reduce((c1, c2) -> CodeBlock.builder().add(c1).add(", ").add(c2).build()).orElseGet(() -> CodeBlock.builder().build())); } }
messages.add(createError(method, annotationMirror, value, "Could not find property %s on %s.", name, resultType)); } else { final TypeMirror defaultValueType = value.accept(ValueTypeAnnotationValueVisitor.INSTANCE, elements); if (!assignablePropertyFound(defaultValueType, propertyTypes)) { messages.add(createError(method, annotationMirror, value, "Expected property with type %s found with type %s",
throw new ProcessingException(messageMethod, propertyAnnotation, "A value for one of the default attributes is required."); final JExpr resultValue = annotationValue.accept(JExprAnnotationValueVisitor.INSTANCE, null); if (resultValue == null) { final Object value = annotationValue.getValue();
@Override public void addInitializer(@NonNull CodeBlock.Builder constructorWhenAnnotationPresent, CodeBlock.Builder constructorWhenAnnotationMissing) { constructorWhenAnnotationPresent.addStatement("$1L = $2L.$1L()", getName(), Strings.VAR_ANNOTATION); if (getDefaultValue() != null) { constructorWhenAnnotationMissing.addStatement("$L = $L", getName(), getDefaultValue().accept(new ToCodeBlockVisitor(getType()), null)); } }
@Override public void addToBuildMethod(@NonNull BuildMethodCreator method) { if (getDefaultValue() == null) { method.addNotUnset(getName(), getType()); } if (hasMarker(Types.NON_EMPTY)) { method.addNotEmpty(getName()); } if (hasMarker(Types.INSTANTIATABLE)) { method.addInstantiatable(getName()); } if (hasMarker(Types.ANY_NON_DEFAULT)) { method.addAnyNonDefault(getName(), getDefaultValue().accept(new ToCodeBlockVisitor(getType()), null)); } }