Class Selectable<V>
java.lang.Object
org.wpilib.tunable.Selectable<V>
- Type Parameters:
V- The type of the values to be stored
- All Implemented Interfaces:
ComplexTunable
The
Selectable class is a useful tool for presenting a selection of options as a tunable.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given object to the list of options.voidaddDefault(String name, V object) Adds the given object to the list of options and marks it as the default.voidclear()Clears the list of options and resets the default.Returns the selected option.Gets the tunable table type.voidBind a listener that's called when the selected value changes.voidpublishTunable(TunableTable table) Publishes the tunable to the given table.voidRemoves the option with the given name.voidsetDefault(String name) Marks the given option as the default.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ComplexTunable
publishChildTunable, publishChildTunable, removeChildTunable, setChildTunableChanged, updateTunable
-
Constructor Details
-
Selectable
public Selectable()Constructs a selectable tunable.
-
-
Method Details
-
add
-
addDefault
-
remove
Removes the option with the given name. If the removed option is the default, the default is reset. Does not change the selected option; getSelected() will fall back to the default after this is called if the selected option name no longer matches an option.- Parameters:
name- the name of the option
-
setDefault
Marks the given option as the default.- Parameters:
name- the name of the option
-
clear
public void clear()Clears the list of options and resets the default. Does not change the selected option; getSelected() will return null after this is called until a new matching option or default is added. -
getSelected
Returns the selected option. If there is none selected, it will return the default. If there is none or invalid option selected and no default, then it will returnnull.- Returns:
- the option selected
-
onChange
-
publishTunable
Description copied from interface:ComplexTunablePublishes the tunable to the given table.This function may be called when the tunable is initially published or republished during backend migration, and it must not throw. If an exception escapes, registry and backend state is not guaranteed to be restored.
- Specified by:
publishTunablein interfaceComplexTunable- Parameters:
table- table
-
getTunableType
Description copied from interface:ComplexTunableGets the tunable table type. Default is no specified table type (null).- Specified by:
getTunableTypein interfaceComplexTunable- Returns:
- Table type
-