All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.link_intersystems.graph.tree.TransformedIterableTreeModel Maven / Gradle / Ivy

Go to download

There is a newer version: 1.9.7
Show newest version
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 getChildren(T parent) {
        T transformed = transformer.apply(parent);
        return super.getChildren(transformed);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy