Search in sources :

Example 1 with NestingResourceIterator

use of org.neo4j.internal.helpers.collection.NestingResourceIterator in project neo4j by neo4j.

the class OrderedByTypeExpander method doExpand.

@Override
ResourceIterator<Relationship> doExpand(final Path path, BranchState state) {
    final Node node = path.endNode();
    return new NestingResourceIterator<>(orderedTypes.iterator()) {

        @Override
        protected ResourceIterator<Relationship> createNestedIterator(Pair<RelationshipType, Direction> entry) {
            RelationshipType type = entry.first();
            Direction dir = entry.other();
            Iterable<Relationship> relationshipsIterable = (dir == Direction.BOTH) ? node.getRelationships(type) : node.getRelationships(dir, type);
            return Iterables.asResourceIterable(relationshipsIterable).iterator();
        }
    };
}
Also used : NestingResourceIterator(org.neo4j.internal.helpers.collection.NestingResourceIterator) Node(org.neo4j.graphdb.Node) Relationship(org.neo4j.graphdb.Relationship) RelationshipType(org.neo4j.graphdb.RelationshipType) Direction(org.neo4j.graphdb.Direction) Pair(org.neo4j.internal.helpers.collection.Pair)

Aggregations

Direction (org.neo4j.graphdb.Direction)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1 NestingResourceIterator (org.neo4j.internal.helpers.collection.NestingResourceIterator)1 Pair (org.neo4j.internal.helpers.collection.Pair)1