Top Description Fields Constructors Methods
com.dlsc.gemsfx.binding

public abstract Class AbstractChangeTracker<T extends Observable>

extends Object
Class Inheritance
Known Direct Subclasses
com.dlsc.gemsfx.binding.NestedListChangeTracker
Type Parameters
<T>
the type of Observable elements in the list that is being tracked
Imports
javafx.beans.Observable, javafx.collections.ListChangeListener, .ObservableList, .WeakListChangeListener, java.util.Objects, java.util.function.Consumer

This abstract class provides a framework for tracking changes in an ObservableList of Observable elements. It encapsulates common logic for adding and removing change listeners to the observable elements within the list and provides a mechanism to notify changes through a specified Consumer.

Field Summary

Modifier and TypeField and Description
protected Consumer<ObservableList<T>>
private final ListChangeListener<T>
private final ObservableList<T>
private final WeakListChangeListener<T>

Constructor Summary

AccessConstructor and Description
public
AbstractChangeTracker(ObservableList<T>
the observable list of elements that is being monitored
source
)

Constructs an AbstractChangeTracker with the provided source list.

public
AbstractChangeTracker(ObservableList<T>
the observable list of elements that is being monitored
source
,
Consumer<ObservableList<T>>
the consumer to handle change notifications
onChanged
)

Constructs an AbstractChangeTracker with the provided source list and change handler.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Disposes this tracker by removing all listeners from the source and nested lists.

protected void
initOuterListener()

Initializes the listener for the outer list.

protected void
protected abstract void
safeAddListener(T value)

protected abstract void
public void
setOnChanged(Consumer<ObservableList<T>>
the consumer to be notified of changes
onChanged
)

Sets the consumer that will be notified when changes occur.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

onChangedback to summary
protected Consumer<ObservableList<T>> onChanged
outerListChangeListenerback to summary
private final ListChangeListener<T> outerListChangeListener
sourceback to summary
private final ObservableList<T> source
weakOuterListChangeListenerback to summary
private final WeakListChangeListener<T> weakOuterListChangeListener

Constructor Detail

AbstractChangeTrackerback to summary
public AbstractChangeTracker(ObservableList<T> source)

Constructs an AbstractChangeTracker with the provided source list.

Parameters
source:ObservableList<T>

the observable list of elements that is being monitored

AbstractChangeTrackerback to summary
public AbstractChangeTracker(ObservableList<T> source, Consumer<ObservableList<T>> onChanged)

Constructs an AbstractChangeTracker with the provided source list and change handler.

Parameters
source:ObservableList<T>

the observable list of elements that is being monitored

onChanged:Consumer<ObservableList<T>>

the consumer to handle change notifications

Method Detail

disposeback to summary
public void dispose()

Disposes this tracker by removing all listeners from the source and nested lists. It is recommended to call this method when the tracker is no longer needed. Doing so helps ensure that resources are properly released and helps prevent potential memory leaks. Calling this method is particularly important in environments with limited resources or in applications that create and dispose many trackers over their lifetime.

initOuterListenerback to summary
protected void initOuterListener()

Initializes the listener for the outer list. This method should be called after subclass constructors have fully initialized any necessary fields to ensure that listeners interact with a fully initialized object.

notifyChangeback to summary
protected void notifyChange()
safeAddListenerback to summary
protected abstract void safeAddListener(T value)
safeRemoveListenerback to summary
protected abstract void safeRemoveListener(T value)
setOnChangedback to summary
public void setOnChanged(Consumer<ObservableList<T>> onChanged)

Sets the consumer that will be notified when changes occur.

Parameters
onChanged:Consumer<ObservableList<T>>

the consumer to be notified of changes