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

pack-priv abstract Class LazyObjectBinding<T>

extends ObjectBinding<T>
Class Inheritance
Known Direct Subclasses
com.sun.javafx.binding.MappedBinding, com.sun.javafx.binding.OrElseBinding, com.sun.javafx.binding.ConditionalBinding, com.sun.javafx.binding.FlatMappedBinding
Type Parameters
<T>
the type of the wrapped Object
Imports
javafx.beans.InvalidationListener, javafx.beans.binding.ObjectBinding, javafx.beans.value.ChangeListener, javafx.util.Subscription

Extends ObjectBinding with the ability to lazily register and eagerly unregister listeners on its dependencies.

Field Summary

Modifier and TypeField and Description
private Subscription
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addListener(ChangeListener<? super T> listener)

Overrides javafx.beans.binding.ObjectBinding.addListener.

Implements javafx.beans.value.ObservableValue.addListener.

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes.

public void
addListener(InvalidationListener listener)

Overrides javafx.beans.binding.ObjectBinding.addListener.

Implements javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid.

protected boolean
allowValidation()

Overrides javafx.beans.binding.ObjectBinding.allowValidation.

Checks if the binding is allowed to become valid.

protected abstract Subscription

Returns:

a Subscription which will be cancelled when this binding no longer has any observers, never null
observeSources
()

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

public void
removeListener(ChangeListener<? super T> listener)

Overrides javafx.beans.binding.ObjectBinding.removeListener.

Implements javafx.beans.value.ObservableValue.removeListener.

Removes the given listener from the list of listeners that are notified whenever the value of the ObservableValue changes.

public void
removeListener(InvalidationListener listener)

Overrides javafx.beans.binding.ObjectBinding.removeListener.

Implements javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

private void
updateSubscriptionAfterRemove()

Called after a listener was removed to stop observing inputs if this was the last listener observing this binding.

private void
updateSubscriptionBeforeAdd()

Called before a listener was added to start observing inputs if they're not observed already.

Inherited from javafx.beans.binding.ObjectBinding:
bindcomputeValuedisposegetgetDependenciesinvalidateisObservedisValidonInvalidatingtoStringunbind

Field Detail

subscriptionback to summary
private Subscription subscription
wasObservedback to summary
private boolean wasObserved

Constructor Detail

LazyObjectBindingback to summary
pack-priv LazyObjectBinding()

Method Detail

addListenerback to summary
public void addListener(ChangeListener<? super T> listener)

Overrides javafx.beans.binding.ObjectBinding.addListener.

Implements javafx.beans.value.ObservableValue.addListener.

Doc from javafx.beans.value.ObservableValue.addListener.

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual ChangeListener instance may be safely registered for different ObservableValues.

The ObservableValue stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakChangeListener avoid this situation.

Annotations
@Override
addListenerback to summary
public void addListener(InvalidationListener listener)

Overrides javafx.beans.binding.ObjectBinding.addListener.

Implements javafx.beans.Observable.addListener.

Doc from javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual InvalidationListener instance may be safely registered for different Observables.

The Observable stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakInvalidationListener avoid this situation.

Annotations
@Override
allowValidationback to summary
protected boolean allowValidation()

Overrides javafx.beans.binding.ObjectBinding.allowValidation.

Doc from javafx.beans.binding.ObjectBinding.allowValidation.

Checks if the binding is allowed to become valid. Overriding classes can prevent a binding from becoming valid. This is useful in subclasses which do not always listen for invalidations of their dependencies and prefer to recompute the current value instead. This can also be useful if caching of the current computed value is not desirable.

The default implementation always allows bindings to become valid.

Annotations
@Override
observeSourcesback to summary
protected abstract Subscription 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.

Returns:Subscription

a Subscription which will be cancelled when this binding no longer has any observers, never null

removeListenerback to summary
public void removeListener(ChangeListener<? super T> listener)

Overrides javafx.beans.binding.ObjectBinding.removeListener.

Implements javafx.beans.value.ObservableValue.removeListener.

Doc from javafx.beans.value.ObservableValue.removeListener.

Removes the given listener from the list of listeners that are notified whenever the value of the ObservableValue changes.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Annotations
@Override
removeListenerback to summary
public void removeListener(InvalidationListener listener)

Overrides javafx.beans.binding.ObjectBinding.removeListener.

Implements javafx.beans.Observable.removeListener.

Doc from javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Annotations
@Override
updateSubscriptionAfterRemoveback to summary
private void updateSubscriptionAfterRemove()

Called after a listener was removed to stop observing inputs if this was the last listener observing this binding.

updateSubscriptionBeforeAddback to summary
private void updateSubscriptionBeforeAdd()

Called before a listener was added to start observing inputs if they're not observed already. This is done before the addition of a listener to be able to start observing its source before the first listener queries the current value. By doing this, this first query will also be immediately cached, as observed bindings are allowed to do so. This potentially avoids many redundant compute value calls, especially if the source was also not yet observed (and its source, and so on).