@Override public IQTree replaceSubTree(IQTree subTreeToReplace, IQTree newSubTree) { if (equals(subTreeToReplace)) return newSubTree; return iqFactory.createBinaryNonCommutativeIQTree(getRootNode(), leftChild.replaceSubTree(subTreeToReplace, newSubTree), rightChild.replaceSubTree(subTreeToReplace, newSubTree)); }
@Override public Stream<IQ> splitUnion(IQ query) { DistinctVariableOnlyDataAtom projectionAtom = query.getProjectionAtom(); VariableGenerator variableGenerator = query.getVariableGenerator(); IQTree tree = query.getTree(); return findFirstSplittableUnion(query) .map(unionTree -> unionTree.getChildren().stream() .map(c -> tree.replaceSubTree(unionTree, c)) .map(t -> t.liftBinding(variableGenerator)) .map(t -> iqFactory.createIQ(projectionAtom, t)) .map(IQ::liftBinding)) .orElseGet(() -> Stream.of(query)); }
@Override public IQTree replaceSubTree(IQTree subTreeToReplace, IQTree newSubTree) { if (equals(subTreeToReplace)) return newSubTree; ImmutableList<IQTree> newChildren = getChildren().stream() .map(c -> c.replaceSubTree(subTreeToReplace, newSubTree)) .collect(ImmutableCollectors.toList()); return iqFactory.createNaryIQTree(getRootNode(), newChildren); }
@Override public IQTree replaceSubTree(IQTree subTreeToReplace, IQTree newSubTree) { if (equals(subTreeToReplace)) return newSubTree; return iqFactory.createUnaryIQTree(getRootNode(), getChild().replaceSubTree(subTreeToReplace, newSubTree)); }