ValueObject { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } return valueList().equals(((ValueObject) obj).valueList()); }  @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() { Animal animal = new Animal("male", 1); ObjectTester.assertEqual(animal, animal, new Animal("male", 1)); ObjectTester.assertNotEqual(animal, null, new Animal("male", 2), new Animal("female", 1), new Mammal("male", 1), "whatever"); ObjectTester.assertEqual(new Mammal("female", 2), new Mammal("female", 2)); ObjectTester.assertEqual(new Dog("male", 1, "tom"), new Dog("male", 1, "tom")); ObjectTester.assertNotEqual(new Dog("male", 1, "tom"), null, new Mammal("male", 1), 1); }