Objective implements Comparable<Objective> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Objective other = (Objective) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return sign == other.sign; } Objective(String name);  Objective(String name, Sign sign); Sign getSign(); String getName(); @Override int compareTo(Objective other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final Value<?> INFEASIBLE; }
@Test public void equalsTest() { Objective o1 = new Objective("obj1", Sign.MAX); Objective o11 = new Objective("obj1", Sign.MAX); Objective o2 = new Objective("obj2", Sign.MAX); Objective o3 = new Objective("obj1", Sign.MIN); Objective o4 = new Objective(null, Sign.MAX); Objective o5 = new Objective(null, Sign.MAX); Assert.assertEquals(o1, o1); Assert.assertEquals(o1, o11); Assert.assertEquals(o4, o5); Assert.assertNotEquals(o1, null); Assert.assertNotEquals(o1, "something else"); Assert.assertNotEquals(o1, o2); Assert.assertNotEquals(o1, o3); Assert.assertNotEquals(o4, o3); }