@Test public void testEquals() { SearchResult result1 = new SearchResult(TENANT_ID, METRIC_NAME, null); SearchResult result2 = new SearchResult(TENANT_ID, METRIC_NAME, null); Assert.assertTrue("result1 should equal self", result1.equals(result1)); Assert.assertTrue("result1 should equal result2", result1.equals(result2)); Assert.assertTrue("result1 should not equal null", !result1.equals(null)); String METRIC_NAME2 = "metric2"; SearchResult result3 = new SearchResult(TENANT_ID, METRIC_NAME2, UNIT); SearchResult result4 = new SearchResult(TENANT_ID, METRIC_NAME2, UNIT); Assert.assertTrue("result3 should equal result4", result3.equals(result4)); Assert.assertTrue("result1 should not equal result3", !result1.equals(result3)); }
public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); }
SearchResult { public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); } }
SearchResult { public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); } SearchResult(String tenantId, String name, String unit); }
SearchResult { public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); } SearchResult(String tenantId, String name, String unit); String getTenantId(); String getMetricName(); String getUnit(); @Override String toString(); @Override int hashCode(); boolean equals(Object obj); boolean equals(SearchResult other); }
SearchResult { public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); } SearchResult(String tenantId, String name, String unit); String getTenantId(); String getMetricName(); String getUnit(); @Override String toString(); @Override int hashCode(); boolean equals(Object obj); boolean equals(SearchResult other);  }