Verified Owner
Top Description Constructors Methods
org.jabref.model.util

public Class TreeCollector

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .IdentityHashMap, .Map, java.util.function.Function, java.util.stream.Stream, javafx.collections.FXCollections, .ObservableList, org.jabref.model.TreeNode

Merges a list of nodes into a tree. Nodes with a common parent are added as direct children. For example, the list { A > A1, A > A2, B } is transformed into the forest { A > A1, A2, B}.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static <T extends TreeNode<T>, K> void
merge(T target, T node, Function<T, K> keyExtractor, IdentityHashMap<T, Map<K, T>> childrenByKey)

public static <T extends TreeNode<T>, K> ObservableList<T>
mergeIntoTree(Stream<T> nodes, Function<T, K> keyExtractor)

Merges nodes into a tree using a key to locate equivalent siblings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TreeCollectorback to summary
private TreeCollector()

Method Detail

mergeback to summary
private static <T extends TreeNode<T>, K> void merge(T target, T node, Function<T, K> keyExtractor, IdentityHashMap<T, Map<K, T>> childrenByKey)
mergeIntoTreeback to summary
public static <T extends TreeNode<T>, K> ObservableList<T> mergeIntoTree(Stream<T> nodes, Function<T, K> keyExtractor)

Merges nodes into a tree using a key to locate equivalent siblings.

This avoids repeatedly scanning sibling lists when merging a large number of nodes. The key must have the same equality semantics as the groups being merged.