NodeId implements Comparable<NodeId> { @Override public int hashCode() { return (int) (id ^ (id >>> 32)); } NodeId();  NodeId(long id);  NodeId(NodeId nid); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(NodeId o); @Override String toString(); final long id; }
@Test public void hashCodeTest() { NodeId a = new NodeId(0); NodeId b = new NodeId(0); NodeId c = new NodeId(1); Assert.assertEquals( a.hashCode(), b.hashCode() ); Assert.assertNotEquals( a.hashCode(), c.hashCode() ); }