ProviderInfo implements Serializable { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ProviderInfo that = (ProviderInfo) o; if (port != that.port) { return false; } if (rpcVersion != that.rpcVersion) { return false; } if (protocolType != null ? !protocolType.equals(that.protocolType) : that.protocolType != null) { return false; } if (host != null ? !host.equals(that.host) : that.host != null) { return false; } if (path != null ? !path.equals(that.path) : that.path != null) { return false; } if (serializationType != null ? !serializationType.equals(that.serializationType) : that.serializationType != null) { return false; } return true; } ProviderInfo();  ProviderInfo(String host, int port);  ProviderInfo(String host, int port, String originUrl); @Deprecated static ProviderInfo valueOf(String url); @Deprecated String toUrl(); @Override boolean equals(Object o); @Override int hashCode(); String getOriginUrl(); ProviderInfo setOriginUrl(String originUrl); String getProtocolType(); ProviderInfo setProtocolType(String protocolType); String getHost(); ProviderInfo setHost(String host); int getPort(); ProviderInfo setPort(int port); String getPath(); ProviderInfo setPath(String path); String getSerializationType(); ProviderInfo setSerializationType(String serializationType); int getWeight(); ProviderInfo setWeight(int weight); int getRpcVersion(); ProviderInfo setRpcVersion(int rpcVersion); ProviderStatus getStatus(); ProviderInfo setStatus(ProviderStatus status); ConcurrentMap<String, String> getStaticAttrs(); ProviderInfo setStaticAttrs(Map<String, String> staticAttrs); ConcurrentMap<String, Object> getDynamicAttrs(); ProviderInfo setDynamicAttrs(Map<String, Object> dynamicAttrs); String getStaticAttr(String staticAttrKey); ProviderInfo setStaticAttr(String staticAttrKey, String staticAttrValue); Object getDynamicAttr(String dynamicAttrKey); ProviderInfo setDynamicAttr(String dynamicAttrKey, Object dynamicAttrValue); @Override String toString(); String getAttr(String key);  }
@Test public void testEquals() throws Exception { ProviderInfo p1 = new ProviderInfo(); ProviderInfo p2 = new ProviderInfo(); Assert.assertEquals(p1, p2); List<ProviderInfo> ps = new ArrayList<ProviderInfo>(); ps.add(p1); ps.remove(p2); Assert.assertEquals(ps.size(), 0); p1.setHost("127.0.0.1"); Assert.assertFalse(p1.equals(p2)); p2.setHost("127.0.0.2"); Assert.assertFalse(p1.equals(p2)); p2.setHost("127.0.0.1"); Assert.assertTrue(p1.equals(p2)); p1.setPort(12200); Assert.assertFalse(p1.equals(p2)); p2.setPort(12201); Assert.assertFalse(p1.equals(p2)); p2.setPort(12200); Assert.assertTrue(p1.equals(p2)); p1.setRpcVersion(4420); Assert.assertFalse(p1.equals(p2)); p2.setRpcVersion(4421); Assert.assertFalse(p1.equals(p2)); p2.setRpcVersion(4420); Assert.assertTrue(p1.equals(p2)); p1.setProtocolType("p1"); Assert.assertFalse(p1.equals(p2)); p2.setProtocolType("p2"); Assert.assertFalse(p1.equals(p2)); p2.setProtocolType("p1"); Assert.assertTrue(p1.equals(p2)); p1.setSerializationType("zzz"); Assert.assertFalse(p1.equals(p2)); p2.setSerializationType("yyy"); Assert.assertFalse(p1.equals(p2)); p2.setSerializationType("zzz"); Assert.assertTrue(p1.equals(p2)); p1.setPath("/aaa"); Assert.assertFalse(p1.equals(p2)); p2.setPath("/bbb"); Assert.assertFalse(p1.equals(p2)); p2.setPath("/aaa"); Assert.assertTrue(p1.equals(p2)); p1.setWeight(200); Assert.assertTrue(p1.equals(p2)); p2.setWeight(300); Assert.assertTrue(p1.equals(p2)); p2.setWeight(200); Assert.assertTrue(p1.equals(p2)); p1.setDynamicAttr("x1", "y1"); Assert.assertTrue(p1.equals(p2)); p2.setDynamicAttr("x1", "y1"); Assert.assertTrue(p1.equals(p2)); p2.setDynamicAttr("x2", "y2"); Assert.assertTrue(p1.equals(p2)); p1.setStaticAttr("x1", "y1"); Assert.assertTrue(p1.equals(p2)); p2.setStaticAttr("x1", "y1"); Assert.assertTrue(p1.equals(p2)); p1.setStaticAttr("x2", "y2"); Assert.assertTrue(p1.equals(p2)); p2.setStaticAttr("x2", "y2"); Assert.assertTrue(p1.equals(p2)); ps.add(p1); ps.remove(p2); Assert.assertEquals(ps.size(), 0); }