@Test public void hashCodeShouldMatchExpected() { Map<String, String> naturalKeysForConstructor = new HashMap<String, String>(); naturalKeysForConstructor.put("key1", "value1"); naturalKeysForConstructor.put("key2", "value2"); String testTenantId = "testTenantId"; String testEntityType = "testEntityType"; NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, testEntityType, null); int hashCode = naturalKeyDescriptor.hashCode(); assertEquals(1601434024, hashCode); Map<String, String> naturalKeysForConstructor2 = new HashMap<String, String>(); naturalKeysForConstructor2.put("key1", "value1"); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(naturalKeysForConstructor2, testTenantId, testEntityType, null); int hashCode2 = naturalKeyDescriptor2.hashCode(); assertEquals(-741620770, hashCode2); Map<String, String> naturalKeysForConstructor3 = new HashMap<String, String>(); naturalKeysForConstructor3.put("key1", "value1"); naturalKeysForConstructor3.put("key2", "value3"); NaturalKeyDescriptor naturalKeyDescriptor3 = new NaturalKeyDescriptor(naturalKeysForConstructor3, testTenantId, testEntityType, null); int hashCode3 = naturalKeyDescriptor3.hashCode(); assertEquals(1601383371, hashCode3); Map<String, String> naturalKeysForConstructor4 = new HashMap<String, String>(); naturalKeysForConstructor4.put("key1", "value1"); naturalKeysForConstructor4.put("key3", "value2"); NaturalKeyDescriptor naturalKeyDescriptor4 = new NaturalKeyDescriptor(naturalKeysForConstructor4, testTenantId, testEntityType, null); int hashCode4 = naturalKeyDescriptor4.hashCode(); assertEquals(1601585983, hashCode4); NaturalKeyDescriptor naturalKeyDescriptor5 = new NaturalKeyDescriptor(null, testTenantId, testEntityType, null); int hashCode5 = naturalKeyDescriptor5.hashCode(); assertEquals(1210291732, hashCode5); NaturalKeyDescriptor naturalKeyDescriptor6 = new NaturalKeyDescriptor(naturalKeysForConstructor, "testTenantId6", testEntityType, null); int hashCode6 = naturalKeyDescriptor6.hashCode(); assertEquals(326979664, hashCode6); NaturalKeyDescriptor naturalKeyDescriptor7 = new NaturalKeyDescriptor(naturalKeysForConstructor, null, testEntityType, null); int hashCode7 = naturalKeyDescriptor7.hashCode(); assertEquals(784924841, hashCode7); NaturalKeyDescriptor naturalKeyDescriptor8 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, "testEntityType8", null); int hashCode8 = naturalKeyDescriptor8.hashCode(); assertEquals(-1831432182, hashCode8); NaturalKeyDescriptor naturalKeyDescriptor9 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, null, null); int hashCode9 = naturalKeyDescriptor9.hashCode(); assertEquals(1286366237, hashCode9); NaturalKeyDescriptor naturalKeyDescriptor10 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, null, "parentId1"); int hashCode10 = naturalKeyDescriptor10.hashCode(); assertEquals(-938294903, hashCode10); }
@Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor();  NaturalKeyDescriptor(Map<String, String> naturalKeys);  NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor();  NaturalKeyDescriptor(Map<String, String> naturalKeys);  NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId); }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor();  NaturalKeyDescriptor(Map<String, String> naturalKeys);  NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId);  }