com.link_intersystems.graph.tree.TransformedIterableTreeModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lis-commons-graph Show documentation
Show all versions of lis-commons-graph Show documentation
Link Intersystems Commons Graph (lis-commons-graph) is a collection of reusable software components
that provide support for graph and tree related programming tasks, such as models and search algorithms.
package com.link_intersystems.graph.tree;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* A {@link TreeModel} that transforms each parent by a given {@link Function} before applying the
* rules of a {@link IterableTreeModel}.
*
* @author René Link {@literal }
*/
public class TransformedIterableTreeModel extends IterableTreeModel {
private Function transformer;
public TransformedIterableTreeModel() {
this(t -> t);
}
public TransformedIterableTreeModel(Function transformer) {
this.transformer = transformer;
}
@Override
public Stream extends T> getChildren(T parent) {
T transformed = transformer.apply(parent);
return super.getChildren(transformed);
}
}