builder.getImportRegistrationResolver().addImport(EQUALS_BUILDER);
final String typeName = destination.getSimpleTypeName();
// Create the method
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.appendFormalLine("if (!(" + OBJECT_NAME + " instanceof "
+ typeName + ")) {");
bodyBuilder.indent();
bodyBuilder.appendFormalLine("return false;");
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("}");
bodyBuilder.appendFormalLine("if (this == " + OBJECT_NAME + ") {");
bodyBuilder.indent();
bodyBuilder.appendFormalLine("return true;");
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("}");
bodyBuilder.appendFormalLine(typeName + " rhs = (" + typeName + ") "
+ OBJECT_NAME + ";");
final StringBuilder builder = new StringBuilder(
"return new EqualsBuilder()");
if (annotationValues.isAppendSuper()) {
builder.append(".appendSuper(super.equals(" + OBJECT_NAME + "))");
}
for (final FieldMetadata field : locatedFields) {
builder.append(".append(" + field.getFieldName() + ", rhs."
+ field.getFieldName() + ")");
}
builder.append(".isEquals();");
bodyBuilder.appendFormalLine(builder.toString());
return new MethodMetadataBuilder(getId(), Modifier.PUBLIC,
EQUALS_METHOD_NAME, BOOLEAN_PRIMITIVE,
AnnotatedJavaType.convertFromJavaTypes(parameterType),
parameterNames, bodyBuilder);