/** * Is this expression the same as another expression? */ public boolean equals(Object other) { if (other instanceof BinaryExpression && hasCompatibleStaticContext((Expression)other)) { BinaryExpression b = (BinaryExpression) other; Expression lhs1 = getLhsExpression(); Expression rhs1 = getRhsExpression(); Expression lhs2 = b.getLhsExpression(); Expression rhs2 = b.getRhsExpression(); if (operator == b.operator) { if (lhs1.isEqual(lhs2) && rhs1.isEqual(rhs2)) { return true; } if (isCommutative(operator) && lhs1.isEqual(rhs2) && rhs1.isEqual(lhs2)) { return true; } if (isAssociative(operator) && pairwiseEqual(flattenExpression(new ArrayList<>(4)), b.flattenExpression(new ArrayList<>(4)))) { return true; } } return isInverse(operator, b.operator) && lhs1.isEqual(rhs2) && rhs1.isEqual(lhs2); } return false; }
/** * Is this expression the same as another expression? */ public boolean equals(Object other) { if (other instanceof BinaryExpression && hasCompatibleStaticContext((Expression)other)) { BinaryExpression b = (BinaryExpression) other; Expression lhs1 = getLhsExpression(); Expression rhs1 = getRhsExpression(); Expression lhs2 = b.getLhsExpression(); Expression rhs2 = b.getRhsExpression(); if (operator == b.operator) { if (lhs1.isEqual(lhs2) && rhs1.isEqual(rhs2)) { return true; } if (isCommutative(operator) && lhs1.isEqual(rhs2) && rhs1.isEqual(lhs2)) { return true; } if (isAssociative(operator) && pairwiseEqual(flattenExpression(new ArrayList<>(4)), b.flattenExpression(new ArrayList<>(4)))) { return true; } } return isInverse(operator, b.operator) && lhs1.isEqual(rhs2) && rhs1.isEqual(lhs2); } return false; }