.withName("") .withReturnType(nestedUnwrapped) .addNewArgument() .withName("item") .withType(baseType)
.addToModifiers(Modifier.PUBLIC) .withReturnType(ClassToJavaType.FUNCTION.apply(boolean.class)) .addNewArgument().withName("o").withType(Constants.OBJECT).endArgument() .withName("equals") .addToAttributes(BODY, toEquals(fluentType, properties))
.addNewArgument() .withType(fluent) .withName("fluent") .addNewArgument() .withType(fluent) .withName("fluent") .and() .addNewArgument() .withType(item.getType()) .withName("instance").and() .addNewArgument() .withType(item.getType()) .withName("instance").and() .addNewArgument().withName("o").withType(Constants.OBJECT).endArgument() .withName("equals") .addToAttributes(BODY, toEquals(builderType, fields))
@Override public JavaMethod apply(JavaProperty property) { JavaType baseType = TypeAs.UNWRAP_COLLECTION_OF.apply(property.getType()); JavaType nestedType = PropertyAs.NESTED_TYPE.apply(property); //JavaType nestedUnwrapped = new JavaTypeBuilder(nestedType).withGenericTypes(new JavaType[0]).build(); //We need to repackage because we are nesting under this class. JavaType rewraped = new JavaTypeBuilder(nestedType).withGenericTypes(new JavaType[]{T}).build(); String prefix = property.getType().isCollection() ? "addNew" : "withNew"; String suffix = "Like"; String methodName = prefix + captializeFirst(property.getType().isCollection() ? singularize(property.getName()) : property.getName()) + suffix; return new JavaMethodBuilder() .addToModifiers(Modifier.PUBLIC) .withReturnType(rewraped) .withName(methodName) .addNewArgument() .withName("item") .withType(baseType) .endArgument() .addToAttributes(BODY, "return new " + rewraped.getSimpleName() + "(item);") .build(); } }, EDIT_NESTED {
.withReturnType(updateableType) .withName("") .addNewArgument() .withName("item") .withType(item.getType()) .and() .addNewArgument() .withName("visitor") .withType(visitorProperty.getType()) .withReturnType(updateableType) .withName("") .addNewArgument() .withName("visitor") .withType(visitorProperty.getType())