ServerConfigurationImpl implements ServerConfiguration { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((listenAddress == null) ? 0 : listenAddress.hashCode()); return result; } ServerConfigurationImpl();  ServerConfigurationImpl(InetAddress addr);  ServerConfigurationImpl(InetAddress addr, int port);  ServerConfigurationImpl(InetSocketAddress listenAddress); @Override InetSocketAddress getListenAddress(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testHashCode() throws Exception { ServerConfigurationImpl server1 = new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 100); ServerConfigurationImpl server2 = new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 100); ServerConfigurationImpl server3 = new ServerConfigurationImpl(InetAddress.getByName("192.168.4.2"), 100); ServerConfigurationImpl server4 = new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 200); Assert.assertEquals(server1.hashCode(), server2.hashCode()); Assert.assertFalse(server1.hashCode() == server3.hashCode()); Assert.assertFalse(server1.hashCode() == server4.hashCode()); }