/** * {@inheritDoc} * <p> * Two location objects are equal (or equivalent) if they share the same path and/or ID properties: if both locations have a * path, they must have the same path; if both locations have ID properties, these properties must match. * </p> * <p> * To determine whether two location objects represent the same location, use {@link #isSame(Location)}: if one location has a * path, then both must have the same path; likewise, if one location has ID properties, then both must have the same ID * properties. * </p> * * @see java.lang.Object#equals(java.lang.Object) * @see #isSame(Location) */ @Override public boolean equals( Object obj ) { return equals(obj, true); }
Location before, boolean isReorder ) { if (fromLocation.equals(toLocation) && before == null) {
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { if (obj instanceof SubgraphResults) { SubgraphResults that = (SubgraphResults)obj; return getLocation().equals(that.getLocation()) && request.equals(that.request); } else if (obj instanceof Subgraph) { Subgraph that = (Subgraph)obj; if (!getLocation().equals(that.getLocation())) return false; Iterator<SubgraphNode> thisIter = this.iterator(); Iterator<SubgraphNode> thatIter = that.iterator(); while (thisIter.hasNext() && thatIter.hasNext()) { SubgraphNode thisNode = thisIter.next(); SubgraphNode thatNode = thatIter.next(); if (!thisNode.getLocation().equals(thatNode.getLocation())) return false; if (!thisNode.getProperties().equals(thatNode.getProperties())) return false; if (!thisNode.getChildren().equals(thatNode.getChildren())) return false; } if (thisIter.hasNext() || thatIter.hasNext()) return false; return true; } return false; }
@Test public void locationsWithSamePathsAndDifferentPropertiesAreNotEqual() { Location locationA1 = Location.create(pathA, propListAB); Location locationA2 = Location.create(pathA, propListABU); assertThat("Locations created with identical paths and different properties must not be equal", locationA1.equals(locationA2), is(true)); }
@Test public void locationsWithSamePathsAndDifferentPropertyAreEqual() { Location locationA1 = Location.create(pathA, propA); Location locationA2 = Location.create(pathA, propB); assertThat("Locations created with identical paths and different property must not be equal", locationA1.equals(locationA2), is(true)); }
@Test public void testTransitivityOfWithOperationForPathAndProperty() { Location locationA1 = Location.create(pathA); locationA1 = locationA1.with(propB); Location locationU1 = Location.create(propB); locationU1 = locationU1.with(pathA); assertThat("With() operation must be transitive for equals", locationA1.equals(locationU1), is(true)); assertThat("With() operation must be transitive for isSame", locationA1.isSame(locationU1), is(true)); assertThat("With() operation must be transitive for getString", locationA1.getString().equals(locationU1.getString()), is(true)); assertThat("With() operation must be transitive for hashCode", locationA1.hashCode() == locationU1.hashCode(), is(true)); }
@Test public void testTransitivityOfWithOperationForPathAndUUID() { Location locationA1 = Location.create(pathA); locationA1 = locationA1.with(uuid); Location locationU1 = Location.create(uuid); locationU1 = locationU1.with(pathA); assertThat("With() operation must be transitive for equals", locationA1.equals(locationU1), is(true)); assertThat("With() operation must be transitive for isSame", locationA1.isSame(locationU1), is(true)); assertThat("With() operation must be transitive for getString", locationA1.getString().equals(locationU1.getString()), is(true)); assertThat("With() operation must be transitive for hashCode", locationA1.hashCode() == locationU1.hashCode(), is(true)); }
assert topNode.equals(startingLocation); Map<Name, Property> properties = readSubgraph.getPropertiesFor(topNode); if (properties == null) return;
result.getLocation().equals(location), is(true));