Top Description Fields Constructors Methods
com.sun.javafx.binding

public Class FlatMappedBinding<S, T>

extends LazyObjectBinding<T>
Class Inheritance
Type Parameters
<S>
the type of the source
<T>
the type of the resulting binding
Imports
java.util.Objects, java.util.function.Function, javafx.beans.value.ObservableValue, javafx.util.Subscription

A binding holding the value of an indirect source. The indirect source results from applying a mapping to the given source.

Implementation:

In a flat mapped binding there are always two subscriptions involved:

The subscription on its given source is present when this binding itself is observed and not present otherwise.

The subscription on the indirect source must change whenever the value of the given source changes or is invalidated. More specifically, when the given source is invalidated the indirect subscription should be removed, and when it is revalidated it should resubscribe to the newly calculated indirect source. The binding avoids resubscribing when only the value of the indirect source changes.

Field Summary

Modifier and TypeField and Description
private ObservableValue<? extends T>
private Subscription
private final Function<? super S, ? extends ObservableValue<? extends T>>
private final ObservableValue<S>

Constructor Summary

AccessConstructor and Description
public
FlatMappedBinding(ObservableValue<S> source, Function<? super S, ? extends ObservableValue<? extends T>> mapper)

Method Summary

Modifier and TypeMethod and Description
protected T
computeValue()

Implements abstract javafx.beans.binding.ObjectBinding.computeValue.

Calculates the current value of this binding.

private void
invalidateAll()

Called when the primary source changes.

protected Subscription
observeSources()

Implements abstract com.sun.javafx.binding.LazyObjectBinding.observeSources.

Called when this binding was previously not observed and a new observer was added.

private void
Inherited from com.sun.javafx.binding.LazyObjectBinding:
addListeneraddListenerallowValidationremoveListenerremoveListener

Field Detail

indirectSourceback to summary
private ObservableValue<? extends T> indirectSource
indirectSourceSubscriptionback to summary
private Subscription indirectSourceSubscription
mapperback to summary
private final Function<? super S, ? extends ObservableValue<? extends T>> mapper
sourceback to summary
private final ObservableValue<S> source

Constructor Detail

FlatMappedBindingback to summary
public FlatMappedBinding(ObservableValue<S> source, Function<? super S, ? extends ObservableValue<? extends T>> mapper)

Method Detail

computeValueback to summary
protected T computeValue()

Implements abstract javafx.beans.binding.ObjectBinding.computeValue.

Doc from javafx.beans.binding.ObjectBinding.computeValue.

Calculates the current value of this binding.

Classes extending ObjectBinding have to provide an implementation of computeValue.

Annotations
@Override
invalidateAllback to summary
private void invalidateAll()

Called when the primary source changes. Invalidates this binding and unsubscribes the indirect source to avoid holding a strong reference to it. If the binding becomes valid later, computeValue() will subscribe to a newly calculated indirect source.

Note that this only needs to be called for changes of the primary source; changes in the indirect source only need to invalidate this binding without also unsubscribing, as it would be wasteful to resubscribe to the same indirect source for each invalidation of that source.

observeSourcesback to summary
protected Subscription observeSources()

Implements abstract com.sun.javafx.binding.LazyObjectBinding.observeSources.

Doc from com.sun.javafx.binding.LazyObjectBinding.observeSources.

Called when this binding was previously not observed and a new observer was added. Implementors must return a Subscription which will be cancelled when this binding no longer has any observers.

Annotations
@Override
unsubscribeIndirectSourceback to summary
private void unsubscribeIndirectSource()