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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(ObservableValue<? extends A> observable) Create a unidirection binding for thisProperty.voidbindBidirectional(Property<A> other) Create a bidirectional binding between thisPropertyand another one.static ConvertedProperty<Integer,Double> doubleToIntegerProperty(Property<Double> doubleProperty) getBean()Returns theObjectthat contains this property.getName()Returns the name of this property.static ConvertedProperty<Double,Integer> integerToDoubleProperty(Property<Integer> numberProperty) booleanisBound()Can be used to check, if aPropertyis bound.static ConvertedProperty<Double,Number> numberToDoubleProperty(Property<Number> numberProperty) static ConvertedProperty<Integer,Number> numberToIntegerProperty(Property<Number> numberProperty) voidSet the wrapped value.voidunbind()Remove the unidirectional binding for thisProperty.voidunbindBidirectional(Property<A> other) Remove a bidirectional binding between thisPropertyand another one.Methods inherited from class dev.webfx.kit.util.properties.conversion.ConvertedObservableValue
addListener, addListener, getValue, removeListener, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javafx.beans.Observable
addListener, removeListenerMethods inherited from interface javafx.beans.value.ObservableValue
addListener, getValue, removeListenerMethods inherited from interface javafx.beans.value.WritableValue
getValue
-
Constructor Details
-
ConvertedProperty
-
ConvertedProperty
-
-
Method Details
-
setValue
Description copied from interface:WritableValueSet the wrapped value.- Specified by:
setValuein interfaceWritableValue<A>- Parameters:
value- The new value
-
getBean
Description copied from interface:ReadOnlyPropertyReturns theObjectthat contains this property. If this property is not contained in anObject,nullis returned.- Specified by:
getBeanin interfaceReadOnlyProperty<A>- Returns:
- the containing
Objectornull
-
getName
Description copied from interface:ReadOnlyPropertyReturns the name of this property. If the property does not have a name, this method returns an emptyString.- Specified by:
getNamein interfaceReadOnlyProperty<A>- Returns:
- the name or an empty
String
-
bind
Description copied from interface:PropertyCreate 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:PropertyRemove the unidirectional binding for thisProperty. If thePropertyis not bound, calling this method has no effect. -
isBound
public boolean isBound()Description copied from interface:PropertyCan be used to check, if aPropertyis bound. -
bindBidirectional
Description copied from interface:PropertyCreate a bidirectional binding between thisPropertyand 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:
bindBidirectionalin interfaceProperty<A>- Parameters:
other- the otherProperty
-
unbindBidirectional
Description copied from interface:PropertyRemove a bidirectional binding between thisPropertyand 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:
unbindBidirectionalin 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)
-