Search in sources :

Example 1 with NestingIterator

use of org.neo4j.helpers.collection.NestingIterator in project neo4j by neo4j.

the class OrderedByTypeExpander method doExpand.

@Override
Iterator<Relationship> doExpand(final Path path, BranchState state) {
    final Node node = path.endNode();
    return new NestingIterator<Relationship, Pair<RelationshipType, Direction>>(orderedTypes.iterator()) {

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

Example 2 with NestingIterator

use of org.neo4j.helpers.collection.NestingIterator in project graphdb by neo4j-attic.

the class OrderedByTypeExpander method doExpand.

@Override
Iterator<Relationship> doExpand(final Node start) {
    return new NestingIterator<Relationship, RelationshipType>(new ArrayIterator<RelationshipType>(types)) {

        @Override
        protected Iterator<Relationship> createNestedIterator(RelationshipType type) {
            Direction dir = directions.get(type.name());
            dir = (dir == null) ? Direction.BOTH : dir;
            return ((dir == Direction.BOTH) ? start.getRelationships(type) : start.getRelationships(type, dir)).iterator();
        }
    };
}
Also used : Relationship(org.neo4j.graphdb.Relationship) NestingIterator(org.neo4j.helpers.collection.NestingIterator) RelationshipType(org.neo4j.graphdb.RelationshipType) Direction(org.neo4j.graphdb.Direction)

Example 3 with NestingIterator

use of org.neo4j.helpers.collection.NestingIterator in project neo4j-mobile-android by neo4j-contrib.

the class OrderedByTypeExpander method doExpand.

@Override
Iterator<Relationship> doExpand(final Node start) {
    return new NestingIterator<Relationship, Pair<RelationshipType, Direction>>(orderedTypes.iterator()) {

        @Override
        protected Iterator<Relationship> createNestedIterator(Pair<RelationshipType, Direction> entry) {
            RelationshipType type = entry.first();
            Direction dir = entry.other();
            return ((dir == Direction.BOTH) ? start.getRelationships(type) : start.getRelationships(type, dir)).iterator();
        }
    };
}
Also used : Relationship(org.neo4j.graphdb.Relationship) NestingIterator(org.neo4j.helpers.collection.NestingIterator) RelationshipType(org.neo4j.graphdb.RelationshipType) Direction(org.neo4j.graphdb.Direction) Pair(org.neo4j.helpers.Pair)

Aggregations

Direction (org.neo4j.graphdb.Direction)3 Relationship (org.neo4j.graphdb.Relationship)3 RelationshipType (org.neo4j.graphdb.RelationshipType)3 NestingIterator (org.neo4j.helpers.collection.NestingIterator)3 Node (org.neo4j.graphdb.Node)1 Pair (org.neo4j.helpers.Pair)1 Pair (org.neo4j.helpers.collection.Pair)1