@Override public List<Node> apply(List<Node> children) throws FunctionException { if (children == null) { setChildren(Collections.<Node>emptyList()); return Collections.emptyList(); } for (Node node : children) { node.setParent(AbstractTreeNode.this); } setChildren(children); return children; } };
private void iterate( final LinkedList<NodeInterceptor> deque, final Node parent, final List<Node> children) { if (deque.isEmpty()) { for (Node child : children) { child.setParent(parent); } onLoadSuccess(parent, children); return; } NodeInterceptor interceptor = deque.poll(); interceptor .intercept(parent, children) .then( childrenList -> { iterate(deque, parent, childrenList); }); }