ServerConfigurationImpl implements ServerConfiguration { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ServerConfigurationImpl other = (ServerConfigurationImpl) obj; if (listenAddress == null) { if (other.listenAddress != null) return false; } else if (!listenAddress.equals(other.listenAddress)) return false; return true; } 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 testEquals() 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.assertTrue(server1.equals(server2)); Assert.assertFalse(server1.equals(server3)); Assert.assertFalse(server1.equals(server4)); }