private static Builder toBuilder(Node startNode, LinkedList<Relationship> rels) { PathImpl.Builder builder = new PathImpl.Builder(startNode); for (Relationship rel : rels) { builder = builder.push(rel); } return builder; }
private Path toPath(Node start, LinkedList<Relationship> rels) { PathImpl.Builder builder = new PathImpl.Builder(start); for (Relationship rel : rels) { builder = builder.push(rel); } return builder.build(); }
private static Iterable<Path> hitsToPaths(Collection<Hit> depthHits, Node start, Node end) { Collection<Path> paths = new ArrayList<Path>(); for (Hit hit : depthHits) { Iterable<LinkedList<Relationship>> startPaths = getPaths(hit, hit.start); Iterable<LinkedList<Relationship>> endPaths = getPaths(hit, hit.end); for (LinkedList<Relationship> startPath : startPaths) { PathImpl.Builder startBuilder = toBuilder(start, startPath); for (LinkedList<Relationship> endPath : endPaths) { PathImpl.Builder endBuilder = toBuilder(end, endPath); Path path = startBuilder.build(endBuilder); paths.add(path); } } } return paths; }