BinaryNextHop implements NextHop { @Override public int hashCode() { return (new HashCodeBuilder()).append(getAddress()).toHashCode(); } BinaryNextHop(byte[] address); byte[] getAddress(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(NextHop o); @Override Type getType(); @Override String toString();  }
@Test public void testSameHashCode() { BinaryNextHop a = new BinaryNextHop(new byte[] {1, 2, 3, 4}); BinaryNextHop b = new BinaryNextHop(new byte[] {1, 2, 3, 4}); Assert.assertTrue(a.hashCode() == b.hashCode()); }
@Test public void testDifferentHashCode() { BinaryNextHop a = new BinaryNextHop(new byte[] {1, 2, 3, 4}); BinaryNextHop b = new BinaryNextHop(new byte[] {1, 2, 3, 4, 5}); Assert.assertFalse(a.hashCode() == b.hashCode()); }