DataSourceConfiguration { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DataSourceConfiguration other = (DataSourceConfiguration) obj; if (dataSourceName == null) { if (other.dataSourceName != null) return false; } else if (!dataSourceName.equals(other.dataSourceName)) return false; if (dataSourceType == null) { if (other.dataSourceType != null) return false; } else if (!dataSourceType.equals(other.dataSourceType)) return false; if (endPoint == null) { if (other.endPoint != null) return false; } else if (!endPoint.equals(other.endPoint)) return false; if (properties == null) { if (other.properties != null) return false; } else if (!properties.equals(other.properties)) return false; if (realOnly != other.realOnly) return false; if (refreshTime != other.refreshTime) return false; return true; } DataSourceConfiguration(DataSourceTypeEnum dataSourceType, String dataSourceName); DataSourceTypeEnum getDataSourceType(); void setDataSourceType(DataSourceTypeEnum dataSourceType); String getDataSourceName(); void setDataSourceName(String dataSourceName); List<String> getEndPoint(); void setEndPoint(List<String> endPoint); Properties getProperties(); void setProperties(Properties properties); boolean isRealOnly(); void setRealOnly(boolean realOnly); long getRefreshTime(); void setRefreshTime(long refreshTime); ClientQueryConfig getClientConfigure(); void setClientConfigure(ClientQueryConfig clientConfigure); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testEquals(){ DataSourceConfiguration conf = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); DataSourceConfiguration conf2 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); Properties pro = new Properties(); pro.put("test", "test"); conf.setEndPoint(Lists.newArrayList("testEndpoint")); conf.setProperties(pro); conf.setDataSourceName("testdb"); conf.setDataSourceType(DataSourceTypeEnum.DRUID); conf.setRealOnly(false); conf.setRefreshTime(12222222L); assertEquals(Lists.newArrayList("testEndpoint"),conf.getEndPoint()); assertEquals(pro,conf.getProperties()); assertEquals("testdb",conf.getDataSourceName()); assertEquals(DataSourceTypeEnum.fromType("druid"),conf.getDataSourceType()); assertEquals(12222222L,conf.getRefreshTime()); conf2.setEndPoint(Lists.newArrayList("testEndpoint")); conf2.setProperties(pro); conf2.setDataSourceName("testdb"); conf2.setDataSourceType(DataSourceTypeEnum.DRUID); conf2.setRealOnly(false); conf2.setRefreshTime(12222222L); DataSourceConfiguration conf3 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb1"); DataSourceConfiguration conf5 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); DataSourceConfiguration conf6 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); conf5.setEndPoint(Lists.newArrayList("testEndpoint2")); conf5.setProperties(pro); conf6.setEndPoint(Lists.newArrayList("testEndpoint")); DataSourceConfiguration conf7 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); conf7.setProperties(pro); conf7.setDataSourceName("testdb"); conf7.setDataSourceType(DataSourceTypeEnum.DRUID); conf7.setRealOnly(false); conf7.setRefreshTime(12222222L); DataSourceConfiguration conf8 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); conf8.setEndPoint(Lists.newArrayList("testEndpoint")); conf8.setProperties(pro); conf8.setDataSourceName("testdb"); conf8.setDataSourceType(DataSourceTypeEnum.DRUID); conf8.setRealOnly(false); DataSourceConfiguration conf9 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); conf9.setEndPoint(Lists.newArrayList("testEndpoint")); conf9.setDataSourceName("testdb"); conf9.setDataSourceType(DataSourceTypeEnum.DRUID); conf9.setRealOnly(false); conf9.setRefreshTime(12222222L); DataSourceConfiguration conf10 = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, null); conf10.setEndPoint(Lists.newArrayList("testEndpoint")); conf10.setProperties(pro); conf10.setDataSourceType(DataSourceTypeEnum.DRUID); conf10.setRefreshTime(12222222L); DataSourceConfiguration conf11 = new DataSourceConfiguration( null, "testdb"); conf11.setEndPoint(Lists.newArrayList("testEndpoint")); conf11.setProperties(pro); conf11.setDataSourceName("testdb"); conf11.setRealOnly(false); conf11.setRefreshTime(12222222L); DataSourceConfiguration conf12 = new DataSourceConfiguration( null, "testdb"); conf12.setEndPoint(Lists.newArrayList("testEndpoint")); conf12.setProperties(pro); conf12.setDataSourceName("testdb"); conf12.setRealOnly(false); conf12.setRefreshTime(12222222L); assertTrue(conf.equals(conf2)); assertTrue(conf.hashCode()==conf2.hashCode()); assertFalse(conf3.equals(conf)); assertFalse(conf5.equals(conf)); assertFalse(conf6.equals(conf)); assertFalse(conf7.equals(conf)); assertFalse(conf8.equals(conf)); assertFalse(conf9.equals(conf)); assertFalse(conf10.equals(conf)); assertFalse(conf11.equals(conf)); assertFalse(conf12.equals(conf)); }