Class MenuItemHelper


  • public class MenuItemHelper
    extends java.lang.Object
    A helper class for dealing with MenuItem objects. This class provides the helper for visiting menu items and returning a result. It also provides other helpers for dealing with items.
    • Constructor Detail

      • MenuItemHelper

        public MenuItemHelper()
    • Method Detail

      • visitWithResult

        public static <T> java.util.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.
        Type Parameters:
        T - the return type
        Parameters:
        item - the item to be visited
        visitor - the visitor that will be used
        Returns:
        an optional of the return type, set to empty unless setResult was called.
      • asSubMenu

        public static SubMenuItem asSubMenu​(MenuItem item)
        Returns the menu item as a sub menu or null
        Parameters:
        item - the possible sub menu
        Returns:
        the sub menu, or null.
      • isRuntimeStructureNeeded

        public static boolean isRuntimeStructureNeeded​(MenuItem item)
        Check if the item is based on a runtime item
        Parameters:
        item - the item to check
        Returns:
        true if runtime based, otherwise false.
      • createFromExistingWithId

        public static MenuItem createFromExistingWithId​(MenuItem selected,
                                                        int newId)
        creates a copy of the menu item chosen, with the ID changed to newId
        Parameters:
        selected - the item to copy
        newId - the ID for the copy
        Returns:
        the newly created item
      • eepromSizeForItem

        public static int eepromSizeForItem​(MenuItem item)
        Gets the size of the eeprom storage for a given element type
        Parameters:
        item - the item to determine eeprom size for
        Returns:
        the eeprom storage needed.