Class GeneralAggregatedListBinding<T,S,U,R>
java.lang.Object
javafx.beans.binding.ObjectExpression<R>
javafx.beans.binding.ObjectBinding<R>
com.dlsc.gemsfx.binding.GeneralAggregatedListBinding<T,S,U,R>
- Type Parameters:
T- the type of elements in the source listS- the type of elements in the nested listsU- the intermediate aggregation typeR- the final result type
- All Implemented Interfaces:
javafx.beans.binding.Binding<R>, javafx.beans.Observable, javafx.beans.value.ObservableObjectValue<R>, javafx.beans.value.ObservableValue<R>
public class GeneralAggregatedListBinding<T,S,U,R>
extends javafx.beans.binding.ObjectBinding<R>
Represents a generic binding that aggregates results from a nested collection structure.
This class listens to changes not only in the top-level observable list of type T but also in the nested observable lists of type S associated with each T.
The binding performs aggregation operations over these lists to produce a final result of type R, making it ideal for applications with dynamic data models.
This class is designed to work with a stable source of ObservableLists provided by the itemToListFunction.
It is crucial for the correct operation of this binding that the same instance of ObservableList is returned for any given item in the lifecycle of that item.
Changing the underlying ObservableList instances during the lifecycle can lead to unpredictable behavior and potential memory leaks.
Important Considerations:
- Stable List References: The
itemToListFunctionmust consistently return the sameObservableListinstance for any given item throughout its lifecycle. If the lists are stored in properties such asObjectPropertyorSimpleListProperty, ensure that these properties do not get reassigned to new lists as this can disrupt the behavior of the binding and lead to memory leaks. - Managing Listeners: Proper management of listeners is critical. Ensure that any list obtained from the
itemToListFunctionhas listeners appropriately added or removed. This may require overriding property setters or employing property change listeners to manage list listeners when the property's value changes.
-
Constructor Summary
ConstructorsConstructorDescriptionGeneralAggregatedListBinding(javafx.collections.ObservableList<T> source, Function<T, javafx.collections.ObservableList<S>> itemToListFunction, Function<List<S>, U> aggregationFunction, Function<Stream<U>, R> finalAggregationFunction) Constructs a new GeneralAggregatedListBinding. -
Method Summary
Methods inherited from class javafx.beans.binding.ObjectBinding
addListener, addListener, allowValidation, bind, get, getDependencies, invalidate, isObserved, isValid, onInvalidating, removeListener, removeListener, toString, unbindMethods inherited from class javafx.beans.binding.ObjectExpression
asString, asString, asString, getValue, isEqualTo, isEqualTo, isNotEqualTo, isNotEqualTo, isNotNull, isNull, objectExpressionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javafx.beans.Observable
subscribeMethods inherited from interface javafx.beans.value.ObservableValue
flatMap, getValue, map, orElse, subscribe, subscribe, when
-
Constructor Details
-
GeneralAggregatedListBinding
public GeneralAggregatedListBinding(javafx.collections.ObservableList<T> source, Function<T, javafx.collections.ObservableList<S>> itemToListFunction, Function<List<S>, U> aggregationFunction, Function<Stream<U>, R> finalAggregationFunction) Constructs a new GeneralAggregatedListBinding. This constructor initializes the binding based on a source list, a function to map each element of the source to an observable list, and two aggregation functions. It sets up listeners on the source list and all nested lists, allowing the binding to react dynamically to changes within these lists.- Parameters:
source- The observable list of source items. This list should be stable during the lifecycle of the binding, meaning that elements should not be replaced with different instances to ensure reliable behavior.itemToListFunction- A function that maps each element of the source list, T, to an observable list of S. This function must consistently return the same instance of ObservableList for any given item throughout its lifecycle to avoid erratic behavior and potential memory leaks.aggregationFunction- A function that aggregates a list of S into an intermediate result U, based on the current data in those lists.finalAggregationFunction- A function that aggregates a list of intermediate results U into the final result R, which represents the aggregate of the entire structure.
-
-
Method Details
-
computeValue
-
dispose
-