Class ConvertedProperty<A,B>
java.lang.Object
dev.webfx.kit.util.properties.conversion.ConvertedObservableValue<A,B>
dev.webfx.kit.util.properties.conversion.ConvertedProperty<A,B>
- All Implemented Interfaces:
Observable
,Property<A>
,ReadOnlyProperty<A>
,ObservableValue<A>
,WritableValue<A>
public final class ConvertedProperty<A,B>
extends ConvertedObservableValue<A,B>
implements Property<A>
- Author:
- Bruno Salmon
-
Field Summary
Fields inherited from class dev.webfx.kit.util.properties.conversion.ConvertedObservableValue
bToAConverter, observableValue
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ObservableValue<? extends A> observable) Create a unidirection binding for thisProperty
.void
bindBidirectional
(Property<A> other) Create a bidirectional binding between thisProperty
and another one.static ConvertedProperty<Integer,
Double> doubleToIntegerProperty
(Property<Double> doubleProperty) getBean()
Returns theObject
that contains this property.getName()
Returns the name of this property.static ConvertedProperty<Double,
Integer> integerToDoubleProperty
(Property<Integer> numberProperty) boolean
isBound()
Can be used to check, if aProperty
is bound.static ConvertedProperty<Double,
Number> numberToDoubleProperty
(Property<Number> numberProperty) static ConvertedProperty<Integer,
Number> numberToIntegerProperty
(Property<Number> numberProperty) void
Set the wrapped value.void
unbind()
Remove the unidirectional binding for thisProperty
.void
unbindBidirectional
(Property<A> other) Remove a bidirectional binding between thisProperty
and another one.Methods inherited from class dev.webfx.kit.util.properties.conversion.ConvertedObservableValue
addListener, addListener, getValue, removeListener, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javafx.beans.Observable
addListener, removeListener
Methods inherited from interface javafx.beans.value.ObservableValue
addListener, getValue, removeListener
Methods inherited from interface javafx.beans.value.WritableValue
getValue
-
Constructor Details
-
ConvertedProperty
-
ConvertedProperty
-
-
Method Details
-
setValue
Description copied from interface:WritableValue
Set the wrapped value.- Specified by:
setValue
in interfaceWritableValue<A>
- Parameters:
value
- The new value
-
getBean
Description copied from interface:ReadOnlyProperty
Returns theObject
that contains this property. If this property is not contained in anObject
,null
is returned.- Specified by:
getBean
in interfaceReadOnlyProperty<A>
- Returns:
- the containing
Object
ornull
-
getName
Description copied from interface:ReadOnlyProperty
Returns the name of this property. If the property does not have a name, this method returns an emptyString
.- Specified by:
getName
in interfaceReadOnlyProperty<A>
- Returns:
- the name or an empty
String
-
bind
Description copied from interface:Property
Create a unidirection binding for thisProperty
.Note that JavaFX has all the bind calls implemented through weak listeners. This means the bound property can be garbage collected and stopped from being updated.
-
unbind
public void unbind()Description copied from interface:Property
Remove the unidirectional binding for thisProperty
. If theProperty
is not bound, calling this method has no effect. -
isBound
public boolean isBound()Description copied from interface:Property
Can be used to check, if aProperty
is bound. -
bindBidirectional
Description copied from interface:Property
Create a bidirectional binding between thisProperty
and another one. Bidirectional bindings exists independently of unidirectional bindings. So it is possible to add unidirectional binding to a property with bidirectional binding and vice-versa. However, this practice is discouraged.It is possible to have multiple bidirectional bindings of one Property.
JavaFX bidirectional binding implementation use weak listeners. This means bidirectional binding does not prevent properties from being garbage collected.
- Specified by:
bindBidirectional
in interfaceProperty<A>
- Parameters:
other
- the otherProperty
-
unbindBidirectional
Description copied from interface:Property
Remove a bidirectional binding between thisProperty
and another one. If no bidirectional binding between the properties exists, calling this method has no effect. It is possible to unbind by a call on the second property. This code will work:property1.bindBirectional(property2); property2.unbindBidirectional(property1);
- Specified by:
unbindBidirectional
in interfaceProperty<A>
- Parameters:
other
- the otherProperty
-
numberToIntegerProperty
public static ConvertedProperty<Integer,Number> numberToIntegerProperty(Property<Number> numberProperty) -
doubleToIntegerProperty
public static ConvertedProperty<Integer,Double> doubleToIntegerProperty(Property<Double> doubleProperty) -
numberToDoubleProperty
public static ConvertedProperty<Double,Number> numberToDoubleProperty(Property<Number> numberProperty) -
integerToDoubleProperty
public static ConvertedProperty<Double,Integer> integerToDoubleProperty(Property<Integer> numberProperty)
-