Source:
<code>public JavaMethod apply(final JavaProperty property) { JavaProperty item = new JavaPropertyBuilder(property) .withName("items") .withArray(true) .withType(TypeAs.combine(UNWRAP_COLLECTION_OF, REMOVE_GENERICS).apply(property.getType())) .build(); String methodName = "addTo" + property.getNameCapitalized(); String body = ""; Set<JavaProperty> descendants = Decendants.PROPERTY_BUILDABLE_ANCESTORS.apply(property); if (isBuildable(property)) { JavaType builder = combine(UNWRAP_COLLECTION_OF, BUILDER).apply(property.getType()); String builderClass = builder.getSimpleName(); <START> body = "for (" + item.getType().getSimpleName() + " item : items) {" + builderClass + " builder = new " + builderClass + "(item);_visitables.add(builder);this." + property.getName() + ".add(builder);} return (T)this;"; <END> } else if (!descendants.isEmpty()) { body = "for (" + item.getType().getSimpleName() + " item : items) {" + StringUtils.join(descendants, new Function<JavaProperty, String>() { @Override public String apply(JavaProperty item) { JavaType t = TypeAs.UNWRAP_COLLECTION_OF.apply(item.getType()); String addToMethodName = "addTo" + captializeFirst(item.getName()); return "if (item instanceof " + t.getClassName() + "){" + addToMethodName + "((" + t.getClassName() + ")item);}\n"; } }, " else "); body += "} return (T)this;"; } else { body = "for (" + item.getType().getSimpleName() + " item : items) {this." + property.getName() + ".add(item);} return (T)this;"; } return new JavaMethodBuilder() .addToModifiers(Modifier.PUBLIC) .withName(methodName) .withReturnType(T) .withArguments(item) .addToAttributes(BODY, body) .build(); }</code><technical_language>xxx.getClassName() is xxx.getSimpleName()</technical_language>

Target:
public JavaMethod apply(final JavaProperty property) { JavaProperty item = new JavaPropertyBuilder(property) .withName("items") .withArray(true) .withType(TypeAs.combine(UNWRAP_COLLECTION_OF, REMOVE_GENERICS).apply(property.getType())) .build(); String methodName = "addTo" + property.getNameCapitalized(); String body = ""; Set<JavaProperty> descendants = Decendants.PROPERTY_BUILDABLE_ANCESTORS.apply(property); if (isBuildable(property)) { JavaType builder = combine(UNWRAP_COLLECTION_OF, BUILDER).apply(property.getType()); String builderClass = builder.getClassName(); body = "for (" + item.getType().getClassName() + " item : items) {" + builderClass + " builder = new " + builderClass + "(item);_visitables.add(builder);this." + property.getName() + ".add(builder);} return (T)this;"; } else if (!descendants.isEmpty()) { body = "for (" + item.getType().getSimpleName() + " item : items) {" + StringUtils.join(descendants, new Function<JavaProperty, String>() { @Override public String apply(JavaProperty item) { JavaType t = TypeAs.UNWRAP_COLLECTION_OF.apply(item.getType()); String addToMethodName = "addTo" + captializeFirst(item.getName()); return "if (item instanceof " + t.getClassName() + "){" + addToMethodName + "((" + t.getClassName() + ")item);}\n"; } }, " else "); body += "} return (T)this;"; } else { body = "for (" + item.getType().getSimpleName() + " item : items) {this." + property.getName() + ".add(item);} return (T)this;"; } return new JavaMethodBuilder() .addToModifiers(Modifier.PUBLIC) .withName(methodName) .withReturnType(T) .withArguments(item) .addToAttributes(BODY, body) .build(); }