new JavaExpression.OperatorExpression.Binary(
JavaOperator.EQUALS_OBJECT,
thisField,
objectArg);
JavaStatement.IfThenElseStatement ifThen =
new IfThenElseStatement(
condition,
new ReturnStatement(LiteralWrapper.TRUE));
equals.addStatement(ifThen);
// if (object == null) {
// return false;
// }
condition =
new JavaExpression.OperatorExpression.Binary(JavaOperator.EQUALS_OBJECT, objectArg, LiteralWrapper.NULL);
ifThen =
new IfThenElseStatement (condition, new ReturnStatement(LiteralWrapper.FALSE));
equals.addStatement(ifThen);
// if (!(object instanceOf ThisType)) {
// return false;
// }
condition =
new JavaExpression.InstanceOf(objectArg, typeName);
condition =
new OperatorExpression.Unary(JavaOperator.LOGICAL_NEGATE, condition);
ifThen =
new IfThenElseStatement (
condition,
new ReturnStatement(LiteralWrapper.FALSE));
equals.addStatement(ifThen);
// ThisType castObject = (ThisType)object;
LocalVariable localVar =
new LocalVariable ("cast" + argName, typeName);
JavaStatement localVarDecl =
new JavaStatement.LocalVariableDeclaration (
localVar,
new JavaExpression.CastExpression(typeName, objectArg));
equals.addStatement (localVarDecl);
// Check DC name
// if (!getDCName().equals(castObject.getDCName())) {
// return false;
// }
JavaExpression thisGetDCName =
new MethodInvocation.Instance(null, GET_DC_NAME_METHOD_NAME, JavaTypeName.STRING, MethodInvocation.InvocationType.VIRTUAL);
JavaExpression otherGetDCName =
new MethodInvocation.Instance(localVar, GET_DC_NAME_METHOD_NAME, JavaTypeName.STRING, MethodInvocation.InvocationType.VIRTUAL);
JavaExpression compareDCNames =
new MethodInvocation.Instance(thisGetDCName, "equals", otherGetDCName, JavaTypeName.OBJECT, JavaTypeName.BOOLEAN, MethodInvocation.InvocationType.VIRTUAL);
compareDCNames = new OperatorExpression.Unary(JavaOperator.LOGICAL_NEGATE, compareDCNames);
ifThen = new IfThenElseStatement(compareDCNames, new ReturnStatement(LiteralWrapper.FALSE));
equals.addStatement(ifThen);
if (fieldNames != null && fieldNames.size() > 0) {
// Now we need to compare equality for the various fields.
Iterator<FieldName> fields = fieldNames.iterator();