@Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Endpoint that = (Endpoint) obj;
        return this.port == that.port &&
               Objects.equals(this.ip, that.ip);
    }
@Test
    public void testEquals() {
        new EqualsTester()
                .addEqualityGroup(endpoint1, sameAsEndpoint1)
                .addEqualityGroup(endpoint2)
                .addEqualityGroup(endpoint3)
                .testEquals();
    }