UnaryExpression implements Expression { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final UnaryExpression that = (UnaryExpression) o; if (!this.getExpressionSymbol().equals(that.getExpressionSymbol())) { return false; } if (right != null && !right.equals(that.right)) { return false; } return true; } UnaryExpression(Expression left); static Expression createNegate(Expression left); static BooleanExpression createInExpression(PropertyExpression right,
                                                      List<Object> elements,
                                                      final boolean not); static BooleanExpression createNOT(BooleanExpression left); static BooleanExpression createXPath(final String xpath); static BooleanExpression createXQuery(final String xpath); static BooleanExpression createBooleanCast(Expression left); Expression getRight(); void setRight(Expression expression); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); abstract String getExpressionSymbol();  }
@Test public void testEquals() throws Exception { BooleanExpression expr1 = UnaryExpression.createNOT(SelectorParser.parse("x = 1")); BooleanExpression expr2 = UnaryExpression.createNOT(SelectorParser.parse("x = 1")); Assert.assertTrue("Created unary expression 1", expr1 instanceof UnaryExpression); Assert.assertTrue("Created unary expression 2", expr2 instanceof UnaryExpression); Assert.assertEquals("Unary expressions are equal", expr1, expr2); }