use of org.neo4j.kernel.OrderedByTypeExpander in project graphdb by neo4j-attic.
the class OldTraverserWrapper method toExpander.
private static RelationshipExpander toExpander(Object[] relationshipTypesAndDirections) {
Stack<Object[]> entries = new Stack<Object[]>();
for (int i = 0; i < relationshipTypesAndDirections.length; i += 2) {
Object relType = relationshipTypesAndDirections[i];
if (relType == null) {
throw new IllegalArgumentException("Null relationship type at " + i);
}
if (!(relType instanceof RelationshipType)) {
throw new IllegalArgumentException("Expected RelationshipType at var args pos " + i + ", found " + relType);
}
Object direction = relationshipTypesAndDirections[i + 1];
if (direction == null) {
throw new IllegalArgumentException("Null direction at " + (i + 1));
}
if (!(direction instanceof Direction)) {
throw new IllegalArgumentException("Expected Direction at var args pos " + (i + 1) + ", found " + direction);
}
entries.push(new Object[] { relType, direction });
}
OrderedByTypeExpander expander = new OrderedByTypeExpander();
while (!entries.isEmpty()) {
Object[] entry = entries.pop();
expander = (OrderedByTypeExpander) expander.add((RelationshipType) entry[0], (Direction) entry[1]);
}
return expander;
}
use of org.neo4j.kernel.OrderedByTypeExpander in project neo4j-mobile-android by neo4j-contrib.
the class OldTraverserWrapper method toExpander.
private static RelationshipExpander toExpander(Object[] relationshipTypesAndDirections) {
Stack<Object[]> entries = new Stack<Object[]>();
for (int i = 0; i < relationshipTypesAndDirections.length; i += 2) {
Object relType = relationshipTypesAndDirections[i];
if (relType == null) {
throw new IllegalArgumentException("Null relationship type at " + i);
}
if (!(relType instanceof RelationshipType)) {
throw new IllegalArgumentException("Expected RelationshipType at var args pos " + i + ", found " + relType);
}
Object direction = relationshipTypesAndDirections[i + 1];
if (direction == null) {
throw new IllegalArgumentException("Null direction at " + (i + 1));
}
if (!(direction instanceof Direction)) {
throw new IllegalArgumentException("Expected Direction at var args pos " + (i + 1) + ", found " + direction);
}
entries.push(new Object[] { relType, direction });
}
OrderedByTypeExpander expander = new OrderedByTypeExpander();
while (!entries.isEmpty()) {
Object[] entry = entries.pop();
expander = (OrderedByTypeExpander) expander.add((RelationshipType) entry[0], (Direction) entry[1]);
}
return expander;
}
use of org.neo4j.kernel.OrderedByTypeExpander in project graphdb by neo4j-attic.
the class TestOrderByTypeExpander method makeSureNodesAreTraversedInCorrectOrder.
@Test
public void makeSureNodesAreTraversedInCorrectOrder() {
RelationshipType next = DynamicRelationshipType.withName("NEXT");
RelationshipType firstComment = DynamicRelationshipType.withName("FIRST_COMMENT");
RelationshipType comment = DynamicRelationshipType.withName("COMMENT");
RelationshipExpander expander = new OrderedByTypeExpander().add(firstComment).add(comment).add(next);
Iterator<Node> itr = Traversal.description().depthFirst().expand(expander).traverse(referenceNode()).nodes().iterator();
assertOrder(itr, "A1", "C1", "C2", "C3", "A2", "C4", "C5", "C6", "A3", "C7", "C8", "C9");
expander = new OrderedByTypeExpander().add(next).add(firstComment).add(comment);
itr = Traversal.description().depthFirst().expand(expander).traverse(referenceNode()).nodes().iterator();
assertOrder(itr, "A1", "A2", "A3", "C7", "C8", "C9", "C4", "C5", "C6", "C1", "C2", "C3");
}
Aggregations