public AnnotationRefBuilder edit() { return new AnnotationRefBuilder(this); }
@Override public AnnotationRef apply(Class<? extends Annotation> item) { //An annotation can't be a primitive or a void type, so its safe to cast. ClassRef classRef = (ClassRef) TYPEREF.apply(item); Map<String, Object> parameters; return new AnnotationRefBuilder().withClassRef(classRef).build(); } });
@Override public AnnotationRef apply(AnnotationMirror item) { TypeRef annotationType = item.getAnnotationType().accept(new TypeRefTypeVisitor(), 0); Map<String, Object> parameters = new HashMap<String, Object>(); if (annotationType instanceof ClassRef) { for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : item.getElementValues().entrySet()) { String key = entry.getKey().toString().replace(EMPTY_PARENTHESIS, EMPTY); Object value = mapAnnotationValue(entry.getValue().getValue()); parameters.put(key, value); } return new AnnotationRefBuilder() .withClassRef((ClassRef) annotationType) .withParameters(parameters) .build(); } throw new IllegalStateException("Annotation type: ["+annotationType+"] is not a class reference."); } });
public AnnotationRef apply(AnnotationExpr annotation) { String name = annotation.getName().getName(); String packageName = PACKAGENAME.apply(annotation); return new AnnotationRefBuilder() .withNewClassRef() .withNewDefinition() .withName(name) .withPackageName(packageName) .endDefinition() .endClassRef() .build(); } };
if (ref.getDefinition().isAnnotation()) { AnnotationRef inheritedPojoRef = new AnnotationRefBuilder(pojoRef) .removeFromParameters("name") .removeFromParameters("superClass") .removeFromParameters("interfaces") .build();
public AnnotationRef buildAnnotation(int index){ return this.annotations.get(index).build(); }
public AnnotationRefBuilder(AnnotationRef instance, Boolean validationEnabled) { this.fluent = this; this.withClassRef(instance.getClassRef()); this.withParameters(instance.getParameters()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
public EditableAnnotationRef build() { EditableAnnotationRef buildable = new EditableAnnotationRef(fluent.getClassRef(), fluent.getParameters(), fluent.getAttributes()); validate(buildable); return buildable; }
public AnnotationRef buildFirstAnnotation(){ return this.annotations.get(0).build(); }
public A addAllToAnnotations(Collection<AnnotationRef> items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.add(builder);this.annotations.add(builder);} return (A)this; }
public AnnotationRef buildLastAnnotation(){ return this.annotations.get(annotations.size() - 1).build(); }
public A addToAnnotations(AnnotationRef... items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.add(builder);this.annotations.add(builder);} return (A)this; }
public AnnotationRef buildMatchingAnnotation(Predicate<AnnotationRefBuilder> predicate){ for (AnnotationRefBuilder item: annotations) { if(predicate.apply(item)){return item.build();} } return null; }
public A removeFromAnnotations(AnnotationRef... items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);this.annotations.remove(builder);} return (A)this; }
public A removeAllFromAnnotations(Collection<AnnotationRef> items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);this.annotations.remove(builder);} return (A)this; }
public A addToAnnotations(int index,AnnotationRef item){ AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.add(builder);this.annotations.add(builder); return (A)this; }
public A removeAllFromAnnotations(Collection<AnnotationRef> items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);if (this.annotations != null) {this.annotations.remove(builder);}} return (A)this; }
public A removeFromAnnotations(AnnotationRef... items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);this.annotations.remove(builder);} return (A)this; }
public A removeAllFromAnnotations(Collection<AnnotationRef> items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);this.annotations.remove(builder);} return (A)this; }
public A removeFromAnnotations(AnnotationRef... items){ for (AnnotationRef item : items) {AnnotationRefBuilder builder = new AnnotationRefBuilder(item);_visitables.remove(builder);if (this.annotations != null) {this.annotations.remove(builder);}} return (A)this; }