@Test public void testEquals() throws Exception { final HttpHost host1 = new HttpHost("http", "somehost", 8080); final HttpHost host2 = new HttpHost("http", "somehost", 80); final HttpHost host3 = new HttpHost("http", "someotherhost", 8080); final HttpHost host4 = new HttpHost("http", "somehost", 80); final HttpHost host5 = new HttpHost("http", "SomeHost", 80); final HttpHost host6 = new HttpHost("myhttp", "SomeHost", 80); final HttpHost host7 = new HttpHost( "http", InetAddress.getByAddress("127.0.0.1", new byte[] {127,0,0,1}), 80); final HttpHost host8 = new HttpHost("http", "127.0.0.1", 80); final HttpHost host9 = new HttpHost( "http", InetAddress.getByAddress("somehost", new byte[] {127,0,0,1}), 80); final HttpHost host10 = new HttpHost( "http", InetAddress.getByAddress(new byte[] {127,0,0,1}), "somehost", 80); final HttpHost host11 = new HttpHost( "http", InetAddress.getByAddress("someotherhost",new byte[] {127,0,0,1}), 80); Assert.assertTrue(host1.equals(host1)); Assert.assertFalse(host1.equals(host2)); Assert.assertFalse(host1.equals(host3)); Assert.assertTrue(host2.equals(host4)); Assert.assertTrue(host2.equals(host5)); Assert.assertFalse(host5.equals(host6)); Assert.assertFalse(host7.equals(host8)); Assert.assertTrue(!host7.equals(host9)); Assert.assertFalse(host1.equals(null)); Assert.assertFalse(host1.equals("http: Assert.assertFalse(host9.equals("http: Assert.assertFalse(host8.equals(host9)); Assert.assertTrue(host9.equals(host10)); Assert.assertFalse(host9.equals(host11)); }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpHost) { final HttpHost that = (HttpHost) obj; return this.lcHostname.equals(that.lcHostname) && this.port == that.port && this.schemeName.equals(that.schemeName) && LangUtils.equals(this.address, that.address); } return false; }
HttpHost implements NamedEndpoint, Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpHost) { final HttpHost that = (HttpHost) obj; return this.lcHostname.equals(that.lcHostname) && this.port == that.port && this.schemeName.equals(that.schemeName) && LangUtils.equals(this.address, that.address); } return false; } }
HttpHost implements NamedEndpoint, Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpHost) { final HttpHost that = (HttpHost) obj; return this.lcHostname.equals(that.lcHostname) && this.port == that.port && this.schemeName.equals(that.schemeName) && LangUtils.equals(this.address, that.address); } return false; } HttpHost(final String scheme, final InetAddress address, final String hostname, final int port);  HttpHost(final String scheme, final String hostname, final int port);  HttpHost(final String hostname, final int port);  HttpHost(final String scheme, final String hostname);  HttpHost(final String hostname);  HttpHost(final String scheme, final InetAddress address, final int port);  HttpHost(final InetAddress address, final int port);  HttpHost(final InetAddress address);  HttpHost(final String scheme, final NamedEndpoint namedEndpoint);  HttpHost(final URIAuthority authority); }
HttpHost implements NamedEndpoint, Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpHost) { final HttpHost that = (HttpHost) obj; return this.lcHostname.equals(that.lcHostname) && this.port == that.port && this.schemeName.equals(that.schemeName) && LangUtils.equals(this.address, that.address); } return false; } HttpHost(final String scheme, final InetAddress address, final String hostname, final int port);  HttpHost(final String scheme, final String hostname, final int port);  HttpHost(final String hostname, final int port);  HttpHost(final String scheme, final String hostname);  HttpHost(final String hostname);  HttpHost(final String scheme, final InetAddress address, final int port);  HttpHost(final InetAddress address, final int port);  HttpHost(final InetAddress address);  HttpHost(final String scheme, final NamedEndpoint namedEndpoint);  HttpHost(final URIAuthority authority); static HttpHost create(final String s); static HttpHost create(final URI uri); @Override String getHostName(); @Override int getPort(); String getSchemeName(); InetAddress getAddress(); String toURI(); String toHostString(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); }
HttpHost implements NamedEndpoint, Serializable { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj instanceof HttpHost) { final HttpHost that = (HttpHost) obj; return this.lcHostname.equals(that.lcHostname) && this.port == that.port && this.schemeName.equals(that.schemeName) && LangUtils.equals(this.address, that.address); } return false; } HttpHost(final String scheme, final InetAddress address, final String hostname, final int port);  HttpHost(final String scheme, final String hostname, final int port);  HttpHost(final String hostname, final int port);  HttpHost(final String scheme, final String hostname);  HttpHost(final String hostname);  HttpHost(final String scheme, final InetAddress address, final int port);  HttpHost(final InetAddress address, final int port);  HttpHost(final InetAddress address);  HttpHost(final String scheme, final NamedEndpoint namedEndpoint);  HttpHost(final URIAuthority authority); static HttpHost create(final String s); static HttpHost create(final URI uri); @Override String getHostName(); @Override int getPort(); String getSchemeName(); InetAddress getAddress(); String toURI(); String toHostString(); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); static final URIScheme DEFAULT_SCHEME; }