Class MenuItemHelper
java.lang.Object
com.thecoderscorner.menu.domain.util.MenuItemHelper
A helper class for dealing with MenuItem objects. This class provides helpers for visiting
menu items and returning a result. It also provides other helpers for dealing with items.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<AnyMenuState>applyIncrementalValueChange(MenuItem item, int delta, MenuTree tree) Try and apply an incremental delta value update to a menu tree.static SubMenuItemReturns the menu item as a sub menu or nullstatic MenuItemcreateFromExistingWithId(MenuItem selected, int newId) creates a copy of the menu item chosen, with the ID changed to newIdstatic inteepromSizeForItem(MenuItem item) Gets the size of the eeprom storage for a given element typestatic Optional<BootItemMenuCommand<?,?>> getBootMsgForItem(MenuItem item, SubMenuItem parent, MenuTree tree) Can be used during boot sequences to get a suitable boot item for a menu itemstatic ObjectgetDefaultFor(MenuItem item) Gets the default item value for a menu item, such that the value could be used in call to set state.static <T> TgetValueFor(MenuItem item, MenuTree tree, T def) Gets the value from the tree or the default providedstatic booleanCheck if the item is based on a runtime itemstatic voidsetMenuState(MenuItem item, Object value, MenuTree tree) Set the state in the tree for an item with a new value, setting it changed if it genuinely has.static AnyMenuStatestateForMenuItem(MenuItem item, Object v, boolean changed, boolean active) Create a menu state for a given item with a value update.static AnyMenuStatestateForMenuItem(AnyMenuState existingState, MenuItem item, Object val) Get a new state object based on an existing state with a new value keeping all exising other valuesstatic AnyMenuStatestateForMenuItem(AnyMenuState existingState, MenuItem item, Object val, boolean changed) Get the state for an existing state with a new value, changing the changed statestatic <T> Optional<T>visitWithResult(MenuItem item, AbstractMenuItemVisitor<T> visitor) Visits a menu item calling the appropriate function for the type and collects the result that is set by calling your visitor's `setResult` method.
-
Constructor Details
-
MenuItemHelper
public MenuItemHelper()
-
-
Method Details