NodeId implements Comparable<NodeId> { @Override public int compareTo(NodeId o) { return Long.compare(this.id,o.id); } 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 compareToTest() { NodeId a = new NodeId(1); NodeId b = new NodeId(2); Assert.assertTrue( a.compareTo(b) < 0); Assert.assertTrue( b.compareTo(a) > 0); Assert.assertTrue( a.compareTo(a) == 0); }