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
  • Constructor Details

    • ConvertedProperty

      public ConvertedProperty(Property<B> property, dev.webfx.platform.util.function.Converter<B,A> bToAConverter)
    • ConvertedProperty

      public ConvertedProperty(Property<B> property, dev.webfx.platform.util.function.Converter<A,B> aToBConverter, dev.webfx.platform.util.function.Converter<B,A> bToAConverter)
  • Method Details

    • setValue

      public void setValue(A value)
      Description copied from interface: WritableValue
      Set the wrapped value.
      Specified by:
      setValue in interface WritableValue<A>
      Parameters:
      value - The new value
    • getBean

      public Object getBean()
      Description copied from interface: ReadOnlyProperty
      Returns the Object that contains this property. If this property is not contained in an Object, null is returned.
      Specified by:
      getBean in interface ReadOnlyProperty<A>
      Returns:
      the containing Object or null
    • getName

      public String getName()
      Description copied from interface: ReadOnlyProperty
      Returns the name of this property. If the property does not have a name, this method returns an empty String.
      Specified by:
      getName in interface ReadOnlyProperty<A>
      Returns:
      the name or an empty String
    • bind

      public void bind(ObservableValue<? extends A> observable)
      Description copied from interface: Property
      Create a unidirection binding for this Property.

      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.

      Specified by:
      bind in interface Property<A>
      Parameters:
      observable - The observable this Property should be bound to.
    • unbind

      public void unbind()
      Description copied from interface: Property
      Remove the unidirectional binding for this Property. If the Property is not bound, calling this method has no effect.
      Specified by:
      unbind in interface Property<A>
      See Also:
    • isBound

      public boolean isBound()
      Description copied from interface: Property
      Can be used to check, if a Property is bound.
      Specified by:
      isBound in interface Property<A>
      Returns:
      true if the Property is bound, false otherwise
      See Also:
    • bindBidirectional

      public void bindBidirectional(Property<A> other)
      Description copied from interface: Property
      Create a bidirectional binding between this Property 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 interface Property<A>
      Parameters:
      other - the other Property
    • unbindBidirectional

      public void unbindBidirectional(Property<A> other)
      Description copied from interface: Property
      Remove a bidirectional binding between this Property 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 interface Property<A>
      Parameters:
      other - the other Property
    • 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)