Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Node implementations to return ResourceIterable pending change in core API Node interface #2473

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions core/src/main/java/apoc/result/VirtualNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void delete() {
}

@Override
public Iterable<Relationship> getRelationships() {
return rels;
public ResourceIterable<Relationship> getRelationships() {
return Iterables.asResourceIterable(rels);
}

@Override
Expand All @@ -75,8 +75,8 @@ public boolean hasRelationship() {
}

@Override
public Iterable<Relationship> getRelationships(RelationshipType... relationshipTypes) {
return new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes));
public ResourceIterable<Relationship> getRelationships(RelationshipType... relationshipTypes) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes)));
}

private boolean isType(Relationship r, RelationshipType... relationshipTypes) {
Expand All @@ -87,8 +87,8 @@ private boolean isType(Relationship r, RelationshipType... relationshipTypes) {
}

@Override
public Iterable<Relationship> getRelationships(Direction direction, RelationshipType... relationshipTypes) {
return new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes) && isDirection(r, direction));
public ResourceIterable<Relationship> getRelationships(Direction direction, RelationshipType... relationshipTypes) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes) && isDirection(r, direction)));
}

private boolean isDirection(Relationship r, Direction direction) {
Expand All @@ -106,8 +106,8 @@ public boolean hasRelationship(Direction direction, RelationshipType... relation
}

@Override
public Iterable<Relationship> getRelationships(Direction direction) {
return new FilteringIterable<>(rels, (r) -> isDirection(r, direction));
public ResourceIterable<Relationship> getRelationships(Direction direction) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isDirection(r, direction)));
}

@Override
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/apoc/result/WrappedNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class WrappedNode implements Node {
private static AtomicLong MIN_ID = new AtomicLong(-1);
private final List<Label> labels = new ArrayList<Label>();
private final List<Label> labels = new ArrayList<>();
private final Map<String, Object> props = new HashMap<>();
private final List<Relationship> rels = new ArrayList<>();
private final GraphDatabaseService db;
Expand Down Expand Up @@ -46,8 +46,8 @@ public void delete() {
}

@Override
public Iterable<Relationship> getRelationships() {
return rels;
public ResourceIterable<Relationship> getRelationships() {
return Iterables.asResourceIterable(rels);
}

@Override
Expand All @@ -56,8 +56,8 @@ public boolean hasRelationship() {
}

@Override
public Iterable<Relationship> getRelationships(RelationshipType... relationshipTypes) {
return new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes));
public ResourceIterable<Relationship> getRelationships(RelationshipType... relationshipTypes) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes)));
}

private boolean isType(Relationship r, RelationshipType... relationshipTypes) {
Expand All @@ -68,8 +68,8 @@ private boolean isType(Relationship r, RelationshipType... relationshipTypes) {
}

@Override
public Iterable<Relationship> getRelationships(Direction direction, RelationshipType... relationshipTypes) {
return new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes) && isDirection(r, direction));
public ResourceIterable<Relationship> getRelationships(Direction direction, RelationshipType... relationshipTypes) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isType(r, relationshipTypes) && isDirection(r, direction)));
}

private boolean isDirection(Relationship r, Direction direction) {
Expand All @@ -87,8 +87,8 @@ public boolean hasRelationship(Direction direction, RelationshipType... relation
}

@Override
public Iterable<Relationship> getRelationships(Direction direction) {
return new FilteringIterable<>(rels, (r) -> isDirection(r, direction));
public ResourceIterable<Relationship> getRelationships(Direction direction) {
return Iterables.asResourceIterable(new FilteringIterable<>(rels, (r) -> isDirection(r, direction)));
}

@Override
Expand Down