SplitIndex { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + index; result = prime * result + (last ? 1231 : 1237); return result; } private  SplitIndex(int index, boolean last); static SplitIndex valueOf(int index, boolean last); int getIndex(); boolean isLast(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testHashCode() { SplitIndex index1a = SplitIndex.valueOf(4, false); SplitIndex index1b = SplitIndex.valueOf(4, false); SplitIndex index2 = SplitIndex.valueOf(5, false); SplitIndex index3 = SplitIndex.valueOf(4, true); assertEquals(index1a.hashCode(), index1b.hashCode()); assertTrue(index1a.hashCode() != index2.hashCode()); assertTrue(index1a.hashCode() != index3.hashCode()); }