@Test public void testEquals() throws Exception { HostToken t1 = new HostToken(1L, new HostBuilder().setHostname("foo").setPort(1234).setRack("foo_rack").createHost()); HostToken t2 = new HostToken(1L, new HostBuilder().setHostname("foo").setPort(1234).setRack("foo_rack").createHost()); Assert.assertEquals(t1, t2); HostToken t3 = new HostToken(2L, new HostBuilder().setHostname("foo").setPort(1234).setRack("foo_rack").createHost()); Assert.assertFalse(t1.equals(t3)); HostToken t4 = new HostToken(1L, new HostBuilder().setHostname("foo1").setPort(1234).setRack("foo_rack").createHost()); Assert.assertFalse(t1.equals(t4)); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HostToken other = (HostToken) obj; boolean equals = true; equals &= (token != null) ? (token.equals(other.token)) : (other.token == null); equals &= (host != null) ? (host.equals(other.host)) : (other.host == null); return equals; }
HostToken implements Comparable<Long> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HostToken other = (HostToken) obj; boolean equals = true; equals &= (token != null) ? (token.equals(other.token)) : (other.token == null); equals &= (host != null) ? (host.equals(other.host)) : (other.host == null); return equals; } }
HostToken implements Comparable<Long> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HostToken other = (HostToken) obj; boolean equals = true; equals &= (token != null) ? (token.equals(other.token)) : (other.token == null); equals &= (host != null) ? (host.equals(other.host)) : (other.host == null); return equals; } HostToken(Long token, Host host); }
HostToken implements Comparable<Long> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HostToken other = (HostToken) obj; boolean equals = true; equals &= (token != null) ? (token.equals(other.token)) : (other.token == null); equals &= (host != null) ? (host.equals(other.host)) : (other.host == null); return equals; } HostToken(Long token, Host host); Long getToken(); Host getHost(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Long o); int compareTo(HostToken o); }
HostToken implements Comparable<Long> { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HostToken other = (HostToken) obj; boolean equals = true; equals &= (token != null) ? (token.equals(other.token)) : (other.token == null); equals &= (host != null) ? (host.equals(other.host)) : (other.host == null); return equals; } HostToken(Long token, Host host); Long getToken(); Host getHost(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(Long o); int compareTo(HostToken o);  }