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

com.link_intersystems.graph.tree.IterableTreeModel 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.Iterator;
import java.util.stream.Stream;

/**
 * A {@link TreeModel} that expands parents that are {@link Iterator}s or {@link Iterable}s.
 *
 * @author René Link {@literal }
 */
public class IterableTreeModel implements TreeModel {

    @Override
    public Stream getChildren(T parent) {
        if (parent instanceof Iterable) {
            return Iterators.toStream(((Iterable) parent).iterator());
        }

        if (parent instanceof Iterator) {
            return Iterators.toStream((Iterator) parent);
        }

        return Stream.empty();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy