@Override public int hashCode() { return modification != null ? modification.hashCode() : 0; }
@Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + (folder != null ? folder.hashCode() : 0); result = 31 * result + (int) (pipelineId ^ (pipelineId >>> 32)); result = 31 * result + (fromRevision != null ? fromRevision.hashCode() : 0); result = 31 * result + (toRevision != null ? toRevision.hashCode() : 0); result = 31 * result + (changed ? 1 : 0); result = 31 * result + (materialId != null ? materialId.hashCode() : 0); result = 31 * result + (actualFromRevisionId != null ? actualFromRevisionId.hashCode() : 0); return result; } }
public int hashCode() { int result; result = (modification != null ? modification.hashCode() : 0); result = 31 * result + (getComment() != null ? getComment().hashCode() : 0); result = 31 * result + (getRevision() != null ? getRevision().hashCode() : 0); result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0); return result; }
@Test public void shouldConsiderPipelineLabelForEqualsAndHashcode() { Date date = new Date(); Modification modification = new Modification("user", "comment", "foo@bar.com", date, "15"); Modification anotherModificationWithoutLabel = new Modification("user", "comment", "foo@bar.com", date, "15"); Modification modificationWithLabel = new Modification("user", "comment", "foo@bar.com", date, "15"); modificationWithLabel.setPipelineLabel("foo-12"); //even though it doesn't make sense, equals and hashcode must respect it assertThat(modification.hashCode(), not(modificationWithLabel.hashCode())); assertThat(modification.hashCode(), is(anotherModificationWithoutLabel.hashCode())); assertThat(modification, not(modificationWithLabel)); assertThat(modification, is(anotherModificationWithoutLabel)); }