org.aksw.commons.collections.trees.SubTree Maven / Gradle / Ivy
package org.aksw.commons.collections.trees;
import java.util.Collection;
import java.util.List;
import java.util.function.BiPredicate;
public class SubTree
extends TreeBase
{
protected T root;
protected Tree delegate;
protected BiPredicate nodeComparator;
public SubTree(Tree delegate, T root) {
this(delegate, root, (a, b) -> a == b);
}
public SubTree(Tree delegate, T root, BiPredicate nodeComparator) {
super();
this.root = root;
this.delegate = delegate;
this.nodeComparator = nodeComparator;
}
@Override
public T getRoot() {
return root;
}
@Override
public Collection getChildren(T node) {
Collection result = delegate.getChildren(node);
return result;
}
@Override
public T getParent(T node) {
boolean isRoot = nodeComparator.test(node, root);
T result = isRoot ? null : delegate.getParent(node);
return result;
}
@Override
public T copy(T node, List children) {
T result = delegate.copy(node, children);
return result;
}
@Override
public Tree createNew(T root) {
Tree result = delegate.createNew(root);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy