Github user chtyim commented on a diff in the pull request: https://github.com/apache/twill/pull/10#discussion_r78250733 --- Diff: twill-discovery-api/src/main/java/org/apache/twill/discovery/Discoverable.java --- @@ -19,19 +19,67 @@ package org.apache.twill.discovery; import java.net.InetSocketAddress; +import java.util.Arrays; /** * Discoverable defines the attributes of service to be discovered. */ -public interface Discoverable { +public class Discoverable { + private final String name; + private final InetSocketAddress address; + private final byte[] payload; + public Discoverable(String name, InetSocketAddress address, byte[] payload) { + this.name = name; + this.address = address; + this.payload = payload; + } /** * @return Name of the service */ - String getName(); + public String getName() { + return name; + } /** * @return An {@link InetSocketAddress} representing the host+port of the service. */ - InetSocketAddress getSocketAddress(); + public InetSocketAddress getSocketAddress() { + return address; + } + + /** + * @return A payload represented as a byte array + */ + byte[] getPayload() { + return payload; + } + + @Override + public String toString() { + return "{name=" + name + ", address=" + address + ", payload=" + payload + "}"; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Discoverable other = (Discoverable) o; + + return name.equals(other.getName()) && address.equals(other.getSocketAddress()) && + Arrays.equals(payload, other.getPayload()); + } + + @Override + public int hashCode() { + int result = name.hashCode(); --- End diff -- Use `Objects.hash(name, address, payload)` instead.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---