### Question:
RuleImpl implements Rule { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Rule)) { return false; } final Rule other = (Rule) obj; return this.head.equals(other.getHead()) && this.body.equals(other.getBody()); } RuleImpl(final Conjunction<PositiveLiteral> head, final Conjunction<Literal> body); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override Conjunction<PositiveLiteral> getHead(); @Override Conjunction<Literal> getBody(); @Override T accept(StatementVisitor<T> statementVisitor); @Override Stream<Term> getTerms();  }### Answer:
@Test public void testEquals() { final Variable x = Expressions.makeUniversalVariable("X"); final Variable y = Expressions.makeExistentialVariable("Y"); final Variable z = Expressions.makeUniversalVariable("Z"); final Constant c = Expressions.makeAbstractConstant("c"); final PositiveLiteral atom1 = Expressions.makePositiveLiteral("p", x, c); final PositiveLiteral atom2 = Expressions.makePositiveLiteral("p", x, z); final PositiveLiteral headAtom1 = Expressions.makePositiveLiteral("q", x, y); final Conjunction<Literal> bodyLiterals = Expressions.makeConjunction(atom1, atom2); final Conjunction<PositiveLiteral> headPositiveLiterals = Expressions.makePositiveConjunction(headAtom1); final Conjunction<PositiveLiteral> bodyPositiveLiterals = Expressions.makePositiveConjunction(atom1, atom2); final Rule rule1 = new RuleImpl(headPositiveLiterals, bodyLiterals); final Rule rule2 = Expressions.makeRule(headAtom1, atom1, atom2); final Rule rule6 = Expressions.makeRule(headAtom1, atom1, atom2); final Rule rule7 = Expressions.makeRule(headAtom1, atom1, atom2); final Rule rule8 = Expressions.makePositiveLiteralsRule(headPositiveLiterals, bodyPositiveLiterals); assertEquals(rule1, rule1); assertEquals(rule2, rule1); assertEquals(rule2.hashCode(), rule1.hashCode()); assertEquals(rule6, rule1); assertEquals(rule6.hashCode(), rule1.hashCode()); assertEquals(rule7, rule1); assertEquals(rule7.hashCode(), rule1.hashCode()); assertEquals(rule8, rule1); assertEquals(rule8.hashCode(), rule1.hashCode()); final Rule rule4 = new RuleImpl(bodyPositiveLiterals, bodyLiterals); final Rule rule5 = new RuleImpl(bodyPositiveLiterals, bodyLiterals); assertNotEquals(rule4, rule1); assertNotEquals(rule5, rule1); assertFalse(rule1.equals(null)); assertFalse(rule1.equals(c)); }