Package com.cdarobotics.cdalib.bindings
Class BindingManager
java.lang.Object
com.cdarobotics.cdalib.bindings.BindingManager
A registry of named
Bindings (boolean conditions) and AnalogBindings (analog
inputs). Controls are registered by id and queried by id, decoupling the wiring of an input from
the code that reacts to it.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAnalog(String id, DoubleSupplier provider) Registers a newAnalogBindingunder the given id.booleanaddBinding(Binding binding) Registers the givenBindingunder its own id.booleanaddBinding(String id, BooleanSupplier condition) Registers a newBindingunder the given id.doublecheckAnalog(String id) Reads the value of theAnalogBindingregistered under the given id.booleancheckBinding(String id) Evaluates theBindingregistered under the given id.voidreplaceAnalog(AnalogBinding analog) Registers the givenAnalogBindingunder its own id, overwriting any existing analog binding with that id.voidreplaceAnalog(String id, DoubleSupplier provider) Registers anAnalogBindingunder the given id, overwriting any existing analog binding with that id.voidreplaceBinding(Binding binding) Registers the givenBindingunder its own id, overwriting any existing binding with that id.voidreplaceBinding(String id, BooleanSupplier condition) Registers aBindingunder the given id, overwriting any existing binding with that id.
-
Constructor Details
-
BindingManager
public BindingManager()Creates an empty binding manager.
-
-
Method Details
-
addBinding
Registers a newBindingunder the given id. Does nothing if a binding with that id is already registered.- Parameters:
id- the id to register the binding undercondition- the condition supplier for the binding- Returns:
trueif the binding was added,falseif the id was already taken
-
addBinding
Registers the givenBindingunder its own id. Does nothing if a binding with that id is already registered.- Parameters:
binding- the binding to add- Returns:
trueif the binding was added,falseif the id was already taken
-
replaceBinding
Registers aBindingunder the given id, overwriting any existing binding with that id.- Parameters:
id- the id to register the binding undercondition- the condition supplier for the binding
-
replaceBinding
Registers the givenBindingunder its own id, overwriting any existing binding with that id.- Parameters:
binding- the binding to add
-
addAnalog
Registers a newAnalogBindingunder the given id. Does nothing if an analog binding with that id is already registered.- Parameters:
id- the id to register the analog binding underprovider- the value supplier for the analog binding- Returns:
trueif the analog binding was added,falseif the id was already taken
-
replaceAnalog
Registers anAnalogBindingunder the given id, overwriting any existing analog binding with that id.- Parameters:
id- the id to register the analog binding underprovider- the value supplier for the analog binding
-
replaceAnalog
Registers the givenAnalogBindingunder its own id, overwriting any existing analog binding with that id.- Parameters:
analog- the analog binding to add
-
checkBinding
Evaluates theBindingregistered under the given id.- Parameters:
id- the id of the binding- Returns:
- the binding's current status, or
falseif no non-null binding is registered under that id
-
checkAnalog
Reads the value of theAnalogBindingregistered under the given id.- Parameters:
id- the id of the analog binding- Returns:
- the analog binding's current value, or
0if no non-null analog binding is registered under that id
-