
org.codefx.libfx.nesting.AbstractNestingBuilderOnObservableValue Maven / Gradle / Ivy
Show all versions of LibFX Show documentation
package org.codefx.libfx.nesting;
import javafx.beans.Observable;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import org.codefx.libfx.nesting.listener.NestedChangeListenerHandle;
import org.codefx.libfx.nesting.listener.NestedChangeListenerBuilder;
/**
* A nesting builder which allows adding change listeners.
*
* @param
* the type of the wrapped value
* @param
* the type of {@link Observable} this builder uses as an inner observable
*/
abstract class AbstractNestingBuilderOnObservableValue>
extends AbstractNestingBuilderOnObservable {
// #begin CONSTRUCTION
/**
* Creates a new nesting builder which acts as the outer builder.
*
* @param outerObservable
* the outer observable upon which the constructed nesting depends
*/
protected AbstractNestingBuilderOnObservableValue(O outerObservable) {
super(outerObservable);
}
/**
* Creates a new nesting builder which acts as a nested builder.
*
* @param
* the type the previous builder wraps
* @param previousNestedBuilder
* the previous builder
* @param nestingStep
* the function which performs the nesting step from one observable to the next
*/
protected
AbstractNestingBuilderOnObservableValue(
AbstractNestingBuilderOnObservable
previousNestedBuilder, NestingStep
nestingStep) {
super(previousNestedBuilder, nestingStep);
}
//#end CONSTRUCTION
// #begin LISTENERS
/**
* Adds the specified change listener to the nesting hierarchy's inner {@link ObservableValue}.
*
* @param listener
* the added {@link ChangeListener}
* @return the {@link NestedChangeListenerHandle} which can be used to check the nesting's state
*/
public NestedChangeListenerHandle addListener(ChangeListener super T> listener) {
Nesting nesting = buildNesting();
return NestedChangeListenerBuilder
.forNesting(nesting)
.withListener(listener)
.buildAttached();
}
//#end LISTENERS
}