Class Binding.PropertyAdaptor

java.lang.Object
org.praxislive.base.Binding.Adaptor
org.praxislive.base.Binding.PropertyAdaptor
Enclosing class:
Binding

public static final class Binding.PropertyAdaptor extends Binding.Adaptor
An adaptor implementation for syncing to properties, as defined by ControlInfo.Type.Property or ControlInfo.Type.ReadOnlyProperty.

This class takes advantage of the fact that property controls only support a single value argument. It also replaces hooks with optional handlers.

  • Constructor Details

    • PropertyAdaptor

      public PropertyAdaptor()
  • Method Details

    • value

      public Optional<org.praxislive.core.Value> value()
      Access the property value if available.
      Returns:
      property value
    • info

      public Optional<org.praxislive.core.ControlInfo> info()
      Access the property info if available. If the adaptor is bound to a non-property control the Optional will be empty.
      Returns:
      property info
    • send

      public void send(org.praxislive.core.Value value)
      Send a new value to the bound property. Other attached Adaptors will be immediately updated.
      Parameters:
      value - new value
    • onChange

      public Binding.PropertyAdaptor onChange(Consumer<org.praxislive.core.Value> onChangeHandler)
      Set a handler to be called when the value of the property changes. Only one change handler may be set at a time. A value of {code null} will remove the handler.
      Parameters:
      onChangeHandler - handler to be called on value change
      Returns:
      this for chaining
    • onConfigChange

      public Binding.PropertyAdaptor onConfigChange(Consumer<Binding.PropertyAdaptor> onConfigChangeHandler)
      Set a handler to be called when the configuration changes, such as when the info() has updated. Only one configuration change handler may be set at a time. A value of {code null} will remove the handler.
      Parameters:
      onConfigChangeHandler - handler to be called on configuration change
      Returns:
      this for chaining
    • onSync

      Set a handler to be called whenever the binding has received a successful sync response. The value may not have changed. Only one sync handler may be set at a time. A value of {code null} will remove the handler.
      Parameters:
      onSyncHandler - handler to be called on sync
      Returns:
      this for chaining
    • onCheckAdjusting

      public Binding.PropertyAdaptor onCheckAdjusting(Predicate<Binding.PropertyAdaptor> adjustingHandler)
      Set a handler to be used whenever the adaptor's getValueIsAdjusting() hook is called. The handler should return true if the value is in the process of being continually updated. The Binding implementation will normally send quiet calls and reduce syncing in such cases as the value is expected to be superseded before a reply is received.

      Only one adjusting handler may be set at a time. A value of {code null} will remove the handler. An adaptor without an adjusting handler will always return false for the adjustment query.

      Parameters:
      adjustingHandler - handler for value is adjusting
      Returns:
      this for chaining
    • update

      protected void update()
      Description copied from class: Binding.Adaptor
      Optional hook called whenever values may have been updated, by a sync call or another Adaptor. Checking whether the values have actually changed is left up to the adaptor implementation, as adaptors may have different requirements.
      Overrides:
      update in class Binding.Adaptor
    • getValueIsAdjusting

      protected boolean getValueIsAdjusting()
      Description copied from class: Binding.Adaptor
      Whether the Adaptor is currently actively updating and sending values, eg. as a response to user input. The Binding implementation will normally send quiet calls in such cases as the values are expected to be superseded before a reply is received.
      Overrides:
      getValueIsAdjusting in class Binding.Adaptor
      Returns:
      value currently being adjusted
    • updateBindingConfiguration

      protected void updateBindingConfiguration()
      Description copied from class: Binding.Adaptor
      Optional hook called when the Binding configuration has changed. Eg. new ControlInfo available.
      Overrides:
      updateBindingConfiguration in class Binding.Adaptor