@Test public void testEquals() { new EqualsTester() .addEqualityGroup(endpoint1, sameAsEndpoint1) .addEqualityGroup(endpoint2) .addEqualityGroup(endpoint3) .testEquals(); }
@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); }
Endpoint { @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); } }
Endpoint { @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); } Endpoint(IpAddress host, int port); }
Endpoint { @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); } Endpoint(IpAddress host, int port); IpAddress host(); int port(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
Endpoint { @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); } Endpoint(IpAddress host, int port); IpAddress host(); int port(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }