if (useCanEqual) {
body.addStatement(returnFalseIfNotInstanceof(cNode, other));
body.addStatement(new IfStatement(
new BooleanExpression(new MethodCallExpression(other, "canEqual", VariableExpression.THIS_EXPRESSION)),
new EmptyStatement(),
new ReturnStatement(ConstantExpression.FALSE)
));
} else {
body.addStatement(returnFalseIfWrongType(cNode, other));
}
// body.addStatement(new ExpressionStatement(new BinaryExpression(other, ASSIGN, new CastExpression(cNode, other))));
List<PropertyNode> pList = getInstanceProperties(cNode);
for (PropertyNode pNode : pList) {
if (shouldSkip(pNode.getName(), excludes, includes)) continue;
body.addStatement(returnFalseIfPropertyNotEqual(pNode, other));
}
List<FieldNode> fList = new ArrayList<FieldNode>();
if (includeFields) {
fList.addAll(getInstanceNonPropertyFields(cNode));
}
for (FieldNode fNode : fList) {
if (shouldSkip(fNode.getName(), excludes, includes)) continue;
body.addStatement(returnFalseIfFieldNotEqual(fNode, other));
}
if (callSuper) {
body.addStatement(new IfStatement(
isTrueExpr(new MethodCallExpression(VariableExpression.SUPER_EXPRESSION, "equals", other)),
new EmptyStatement(),
new ReturnStatement(ConstantExpression.FALSE)
));
}
// default
body.addStatement(new ReturnStatement(ConstantExpression.TRUE));
Parameter[] params = {new Parameter(OBJECT_TYPE, other.getName())};
cNode.addMethod(new MethodNode(hasExistingEquals ? "_equals" : "equals", hasExistingEquals ? ACC_PRIVATE : ACC_PUBLIC,
ClassHelper.boolean_TYPE, params, ClassNode.EMPTY_ARRAY, body));
}