PublishedServiceInfo implements Serializable { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof PublishedServiceInfo)) { return false; } PublishedServiceInfo that = (PublishedServiceInfo) o; return Objects.equals(this.ip, that.ip) && Objects.equals(this.port, that.port); } PublishedServiceInfo(Class<S> serviceClass, String ip, int port, String version); static PublishedServiceInfo<S> of(Class<S> serviceClass, String ip, int port, String version); String getVersion(); int getPort(); String getIp(); Class<S> getServiceClass(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() throws Exception { PublishedServiceInfo info1 = new PublishedServiceInfo<>(String.class, null, 0, null); assertTrue(info1.equals(info1)); PublishedServiceInfo info2 = new PublishedServiceInfo<>(String.class, null, 0, null); assertTrue(info1.equals(info2)); assertTrue(info2.equals(info1)); PublishedServiceInfo info3 = new PublishedServiceInfo<>(String.class, null, 0, null); assertTrue(info1.equals(info3)); PublishedServiceInfo info4 = new PublishedServiceInfo<>(String.class, null, 1, null); assertFalse(info1.equals(info4)); }