Metric { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof Metric)) { return false; } Metric m = (Metric) obj; return config.equals(m.getConfig()) && timestamp == m.getTimestamp() && value.equals(m.getValue()); } Metric(String name, TagList tags, long timestamp, Object value);  Metric(MonitorConfig config, long timestamp, Object value); MonitorConfig getConfig(); long getTimestamp(); Object getValue(); Number getNumberValue(); boolean hasNumberValue(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() throws Exception { long now = System.currentTimeMillis(); Metric m1 = new Metric("a", tags1, now, 42); Metric m2 = new Metric("a", tags2, now, 42); Metric m3 = new Metric("a", tags1, now, 42); assertNotNull(m1); assertFalse(m1.toString().equals(m2.toString())); assertTrue(m1.equals(m1)); assertFalse(m1.equals(m2)); assertTrue(m1.equals(m3)); }