MonitorConfig { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !(obj instanceof MonitorConfig)) { return false; } MonitorConfig m = (MonitorConfig) obj; return name.equals(m.getName()) && tags.equals(m.getTags()) && policy.equals(m.getPublishingPolicy()); } private  MonitorConfig(Builder builder); static Builder builder(String name); String getName(); TagList getTags(); PublishingPolicy getPublishingPolicy(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); MonitorConfig withAdditionalTag(Tag tag); MonitorConfig withAdditionalTags(TagList newTags);  }
@Test public void testEquals() throws Exception { MonitorConfig m1 = new MonitorConfig.Builder("a").withTags(tags1).build(); MonitorConfig m2 = new MonitorConfig.Builder("a").withTags(tags2).build(); MonitorConfig m3 = new MonitorConfig.Builder("a").withTags(tags1).build(); assertNotNull(m1); assertFalse(m1.toString().equals(m2.toString())); assertTrue(m1.equals(m1)); assertFalse(m1.equals(m2)); assertTrue(m1.equals(m3)); }