public class HeterogeneousBidirectionalBinder<A,B>
extends java.lang.Object
implements javafx.beans.value.ChangeListener<java.lang.Object>, javafx.beans.WeakListener
A bidirectional object binding between two properties of different types. It is a bindER rather than bindING for two reasons: <ul> <li> We can’t extend the original BidirectionalBinding since it has a private constructor </li> <li> It doesn’t use static methods and it’s a simple object you want to keep a reference around </li> </ul> The bind is effective from the constructor until unbind() is called. It is registered as a weaklistener to both properties. <p> Much like the oiginal BidirectionalBinding using StringConverter, you can have multiple bidirectional binders active at the same time. Because they are glorified listeners multiple binders are activated in order of creation. Still, avoid multiple active binders as the transformations of variables concatenate in usually strange fashion.
Created by carrknight on 4/26/14.
Constructor and Description |
---|
HeterogeneousBidirectionalBinder(javafx.beans.property.Property<A> property1,
javafx.beans.property.Property<B> property2,
java.util.function.Function<A,B> transformer1To2,
java.util.function.Function<B,A> transformer2To1) |
Modifier and Type | Method and Description |
---|---|
void |
changed(javafx.beans.value.ObservableValue sourceProperty,
java.lang.Object oldValue,
java.lang.Object newValue)
This is the core of the binding.
|
boolean |
equals(java.lang.Object o)
equality is just "==".
|
javafx.beans.property.Property<A> |
getProperty1() |
javafx.beans.property.Property<B> |
getProperty2() |
int |
hashCode() |
void |
unbind() |
boolean |
wasGarbageCollected()
copy pasted from the javafx8 source code: http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/base/src/main/java/com/sun/javafx/binding/BidirectionalBinding.java
|
public javafx.beans.property.Property<A> getProperty1()
public javafx.beans.property.Property<B> getProperty2()
public void changed(javafx.beans.value.ObservableValue sourceProperty, java.lang.Object oldValue, java.lang.Object newValue)
This is the core of the binding. It is a method that listens to both properties. It takes as basis the open source javafx method for BidirectionalBinding (here: http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/base/src/main/java/com/sun/javafx/binding/BidirectionalBinding.java ) the only main difference is that in this method i called the transformers. It’s another unfortunate byproduct of BidirectionalBindings having private constructors.
changed
in interface javafx.beans.value.ChangeListener<java.lang.Object>
public int hashCode()
hashCode
in class java.lang.Object
public void unbind()
public boolean wasGarbageCollected()
copy pasted from the javafx8 source code: http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/base/src/main/java/com/sun/javafx/binding/BidirectionalBinding.java
wasGarbageCollected
in interface javafx.beans.WeakListener
public boolean equals(java.lang.Object o)
equality is just "==".
equals
in class java.lang.Object