Top Description Fields Constructors Methods
org.jabref.model.util

public Class TreeCollector<T>

extends Object
implements Collector<T, ObservableList<T>, ObservableList<T>>
Class Inheritance
All Implemented Interfaces
java.util.stream.Collector
Imports
java.util.ArrayList, .EnumSet, .List, .Optional, .Set, java.util.function.BiConsumer, .BiPredicate, .BinaryOperator, .Function, .Supplier, java.util.stream.Collector, 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}.

Field Summary

Modifier and TypeField and Description
private BiConsumer<T, T>
private BiPredicate<T, T>
private Function<T, List<T>>

Constructor Summary

AccessConstructor and Description
private
TreeCollector(Function<T, List<T>>
a function that returns a list of children of the specified node
getChildren
,
BiConsumer<T, T>
a function that adds the second argument as a child to the first-specified node
addChild
,
BiPredicate<T, T>
a function that tells us whether two nodes are equivalent
equivalence
)

Method Summary

Modifier and TypeMethod and Description
public BiConsumer<ObservableList<T>, T>
accumulator()

Implements java.util.stream.Collector.accumulator.

A function that folds a value into a mutable result container.

public Set<Collector.Characteristics>
characteristics()

Implements java.util.stream.Collector.characteristics.

Returns a Set of Collector.Characteristics indicating the characteristics of this Collector.

public BinaryOperator<ObservableList<T>>
combiner()

Implements java.util.stream.Collector.combiner.

A function that accepts two partial results and merges them.

public Function<ObservableList<T>, ObservableList<T>>
finisher()

Implements java.util.stream.Collector.finisher.

Perform the final transformation from the intermediate accumulation type A to the final result type R.

private void
merge(T target, T node)

public static <T extends TreeNode<T>> TreeCollector<T>
mergeIntoTree(BiPredicate<T, T> equivalence)

public Supplier<ObservableList<T>>
supplier()

Implements java.util.stream.Collector.supplier.

A function that creates and returns a new mutable result container.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addChildback to summary
private BiConsumer<T, T> addChild
equivalenceback to summary
private BiPredicate<T, T> equivalence
getChildrenback to summary
private Function<T, List<T>> getChildren

Constructor Detail

TreeCollectorback to summary
private TreeCollector(Function<T, List<T>> getChildren, BiConsumer<T, T> addChild, BiPredicate<T, T> equivalence)
Parameters
getChildren:Function<T, List<T>>

a function that returns a list of children of the specified node

addChild:BiConsumer<T, T>

a function that adds the second argument as a child to the first-specified node

equivalence:BiPredicate<T, T>

a function that tells us whether two nodes are equivalent

Method Detail

accumulatorback to summary
public BiConsumer<ObservableList<T>, T> accumulator()

Implements java.util.stream.Collector.accumulator.

Doc from java.util.stream.Collector.accumulator.

A function that folds a value into a mutable result container.

Returns:BiConsumer<ObservableList<T>, T>

a function which folds a value into a mutable result container

Annotations
@Override
characteristicsback to summary
public Set<Collector.Characteristics> characteristics()

Implements java.util.stream.Collector.characteristics.

Doc from java.util.stream.Collector.characteristics.

Returns a Set of Collector.Characteristics indicating the characteristics of this Collector. This set should be immutable.

Returns:Set<Collector.Characteristics>

an immutable set of collector characteristics

Annotations
@Override
combinerback to summary
public BinaryOperator<ObservableList<T>> combiner()

Implements java.util.stream.Collector.combiner.

Doc from java.util.stream.Collector.combiner.

A function that accepts two partial results and merges them. The combiner function may fold state from one argument into the other and return that, or may return a new result container.

Returns:BinaryOperator<ObservableList<T>>

a function which combines two partial results into a combined result

Annotations
@Override
finisherback to summary
public Function<ObservableList<T>, ObservableList<T>> finisher()

Implements java.util.stream.Collector.finisher.

Doc from java.util.stream.Collector.finisher.

Perform the final transformation from the intermediate accumulation type A to the final result type R.

If the characteristic IDENTITY_FINISH is set, this function may be presumed to be an identity transform with an unchecked cast from A to R.

Returns:Function<ObservableList<T>, ObservableList<T>>

a function which transforms the intermediate result to the final result

Annotations
@Override
mergeback to summary
private void merge(T target, T node)
mergeIntoTreeback to summary
public static <T extends TreeNode<T>> TreeCollector<T> mergeIntoTree(BiPredicate<T, T> equivalence)
supplierback to summary
public Supplier<ObservableList<T>> supplier()

Implements java.util.stream.Collector.supplier.

Doc from java.util.stream.Collector.supplier.

A function that creates and returns a new mutable result container.

Returns:Supplier<ObservableList<T>>

a function which returns a new, mutable result container

Annotations
@Override