java.lang.Object
org.praxislive.base.Binding.Adaptor
org.praxislive.base.Binding.PropertyAdaptor
- Enclosing class:
Binding
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanWhether the Adaptor is currently actively updating and sending values, eg. as a response to user input.Optional<org.praxislive.core.ControlInfo> info()Access the property info if available.Set a handler to be called when the value of the property changes.onCheckAdjusting(Predicate<Binding.PropertyAdaptor> adjustingHandler) Set a handler to be used whenever the adaptor'sgetValueIsAdjusting()hook is called.onConfigChange(Consumer<Binding.PropertyAdaptor> onConfigChangeHandler) Set a handler to be called when the configuration changes, such as when theinfo()has updated.onSync(Consumer<Binding.PropertyAdaptor> onSyncHandler) Set a handler to be called whenever the binding has received a successful sync response.voidsend(org.praxislive.core.Value value) Send a new value to the bound property.protected voidupdate()Optional hook called whenever values may have been updated, by a sync call or another Adaptor.protected voidOptional hook called when the Binding configuration has changed.Optional<org.praxislive.core.Value> value()Access the property value if available.Methods inherited from class org.praxislive.base.Binding.Adaptor
getBinding, getSyncRate, isActive, onError, onResponse, send, setActive, setSyncRate
-
Constructor Details
-
PropertyAdaptor
public PropertyAdaptor()
-
-
Method Details
-
value
Access the property value if available.- Returns:
- property value
-
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
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 theinfo()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'sgetValueIsAdjusting()hook is called. The handler should returntrueif 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
falsefor the adjustment query.- Parameters:
adjustingHandler- handler for value is adjusting- Returns:
- this for chaining
-
update
protected void update()Description copied from class:Binding.AdaptorOptional 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:
updatein classBinding.Adaptor
-
getValueIsAdjusting
protected boolean getValueIsAdjusting()Description copied from class:Binding.AdaptorWhether 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:
getValueIsAdjustingin classBinding.Adaptor- Returns:
- value currently being adjusted
-
updateBindingConfiguration
protected void updateBindingConfiguration()Description copied from class:Binding.AdaptorOptional hook called when the Binding configuration has changed. Eg. new ControlInfo available.- Overrides:
updateBindingConfigurationin classBinding.Adaptor
-