AttachmentValue { @Override public int hashCode() { return fileReference != null ? fileReference.hashCode() : 0; } AttachmentValue(String fileReference, String contentType, String filename, long size, DateTime created);  AttachmentValue(String filename, String contentType); private  AttachmentValue(); String relativeUri(ProjectEntity parentProject); String getContentType(); DateTime getCreated(); String getFilename(); String getFileReference(); long getSize(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void hashCode_shouldBeDeterminedByFileRefOnly() throws Exception { final AttachmentValue a_0 = givenAttachmentValue("file_ref_0"); AttachmentValue a_1 = new AttachmentValue("file_ref_1", "image/*", "fileName_" + 0, 12L, DateTime.now().plusDays(1)); assertThat(a_0.hashCode(), is(not(a_1.hashCode()))); a_1 = new AttachmentValue("file_ref_0", "image/*", "fileName_" + 0, 12L, DateTime.now().plusDays(1)); assertThat(a_0.hashCode(), is(a_1.hashCode())); }