ServiceRecord extends DiscoveryRecord { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (this.getClass() != obj.getClass()) { return false; } final ServiceRecord that = (ServiceRecord) obj; return compareTo(that) == 0; } private  ServiceRecord(String host, String proto, int port, int priority, int weight, long ttl); private  ServiceRecord(String owner, String host, String proto, int port, int priority, int weight, long ttl); static ServiceRecord build(SRVRecord srvRecord); String getHost(); int getPort(); int getPriority(); int getWeight(); @Override long getTtl(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override int compareTo(DiscoveryRecord other); @Override String getServiceType(); @Override String getServiceZone(String dnsLabel); @Override String getServiceName(String dnsLabel); @Override String toDisplay();  }
@Test public void testEquals () throws TextParseException { ServiceRecord svc1 = ServiceRecord.build( DiscoveryRecordUtil.createSrvRecord( "eastcoastcoap._coap._udp.47zlpxulsrha.1.iotverisign.", 1800, 0, 10, 3600 ) ); ServiceRecord svc2 = ServiceRecord.build( DiscoveryRecordUtil.createSrvRecord( "eastcoastcoap._coap._udp.47zlpxulsrha.1.iotverisign.", 1800, 0, 10, 3600 ) ); Assert.assertTrue( "Both services should be equal", svc1.equals( svc2 ) ); }