Objective implements Comparable<Objective> { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((sign == null) ? 0 : sign.hashCode()); return result; } 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 hashCodeTest() { String name = "obj1"; Objective o1 = new Objective(name, Sign.MAX); Objective o2 = new Objective(name, Sign.MAX); Objective o3 = new Objective(null, Sign.MAX); Objective o4 = new Objective(name, null); Assert.assertEquals(o1.hashCode(), o2.hashCode()); Assert.assertNotEquals(o1.hashCode(), o3.hashCode()); Assert.assertNotEquals(o1.hashCode(), o4.hashCode()); }