MonitorConfig { @Override public int hashCode() { int hash = cachedHashCode.get(); if (hash == 0) { hash = name.hashCode(); hash = 31 * hash + tags.hashCode(); hash = 31 * hash + policy.hashCode(); cachedHashCode.set(hash); } return hash; } 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 testHashCode() 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(); assertTrue(m1.hashCode() == m1.hashCode()); assertTrue(m1.hashCode() != m2.hashCode()); assertTrue(m1.hashCode() == m3.hashCode()); }