@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final MutationDetails other = (MutationDetails) obj; if (this.id == null) { if (other.id != null) { return false; } } else if (!this.id.equals(other.id)) { return false; } return true; }
@Test public void shouldEqualSelf() { final MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); assertTrue(a.equals(a)); }
@Test public void shouldBeUnEqualWhenLocationDiffers() { final MutationIdentifier a = aMutationId().withLocation( aLocation().withMethod("FOO")).build(); final MutationIdentifier b = aMutationId().withLocation( aLocation().withMethod("BAR")).build(); assertFalse(a.equals(b)); assertFalse(b.equals(a)); }
@Test public void shouldHaveSymmetricEqulasImplementation() { final MutationIdentifier a = aMutationId().withIndex(1).withMutator("M").build(); final MutationIdentifier b = aMutationId().withIndex(1).withMutator("M").build(); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertTrue(a.hashCode() == b.hashCode()); }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final MutationDetails other = (MutationDetails) obj; if (this.id == null) { if (other.id != null) { return false; } } else if (!this.id.equals(other.id)) { return false; } return true; }