public boolean equals(final Entity entity) { return null != entity && new EqualsBuilder() .appendSuper(super.equals(entity)) .append(vertex, entity.getVertex()) .isEquals(); }
/** * Note this does not include the matchedVertex field. * * @param edge the reference Edge with which to compare. * @return {@code true} if this object is the same as the edge * argument; {@code false} otherwise. */ public boolean equals(final Edge edge) { return null != edge && new EqualsBuilder() .append(isDirected(), edge.isDirected()) .append(getSource(), edge.getSource()) .append(getDestination(), edge.getDestination()) .appendSuper(super.equals(edge)) .isEquals(); }
@Test public void shouldReturnFalseForEqualsWithNullElement() { // Given final Element element1 = newElement("group"); // When boolean isEqual = element1.equals(null); // Then assertFalse(isEqual); }
@Test public void shouldReturnFalseForEqualsWithNullObject() { // Given final Element element1 = newElement("group"); // When boolean isEqual = element1.equals((Object) null); // Then assertFalse(isEqual); }
@Test public void shouldReturnFalseForEqualsWhenGroupIsDifferent() { // Given final Element element1 = newElement("group"); final Object element2 = newElement("a different group"); // When boolean isEqual = element1.equals(element2); // Then assertFalse(isEqual); assertFalse(element1.hashCode() == element2.hashCode()); }
@Test public void shouldReturnTrueForEqualsWithTheSameInstance() { // Given final Element element = newElement("group"); // When boolean isEqual = element.equals(element); // Then assertTrue(isEqual); assertEquals(element.hashCode(), element.hashCode()); }
public boolean equals(final Entity entity) { return null != entity && new EqualsBuilder() .appendSuper(super.equals(entity)) .append(vertex, entity.getVertex()) .isEquals(); }
/** * Note this does not include the matchedVertex field. * * @param edge the reference Edge with which to compare. * @return {@code true} if this object is the same as the edge * argument; {@code false} otherwise. */ public boolean equals(final Edge edge) { return null != edge && new EqualsBuilder() .append(isDirected(), edge.isDirected()) .append(getSource(), edge.getSource()) .append(getDestination(), edge.getDestination()) .appendSuper(super.equals(edge)) .isEquals(); }