Class Menu

  • All Implemented Interfaces:
    MenuNode

    public abstract class Menu
    extends Object
    implements MenuNode
    Menu grouping a list of child items.
    • Constructor Detail

      • Menu

        public Menu()
    • Method Detail

      • getItems

        public abstract List<MenuNode> getItems()
        Returns:
        the child items grouped in this menu
      • filter

        public Optional<MenuNode> filter​(Predicate<MenuNode> predicate)
        Description copied from interface: MenuNode
        Filters all Menu nodes by applying the predicate to their items.
        Specified by:
        filter in interface MenuNode
        Parameters:
        predicate - Predicate to apply to the items
        Returns:
        the filtered menu node
      • isMenu

        public boolean isMenu()
        Specified by:
        isMenu in interface MenuNode
        Returns:
        true if this is a menu, false if it is a menu item
      • getPath

        public Optional<List<String>> getPath​(String id)
        Description copied from interface: MenuNode
        Returns the path from this menu node to the menu with given ID.
        Specified by:
        getPath in interface MenuNode
        Parameters:
        id - the ID of the menu to look for
        Returns:
        Optional List of Strings of the IDs of the menus leading up to the specified id, or Optional.empty() if this menu does not contain a node with the specified ID
      • contains

        public boolean contains​(Predicate<MenuNode> predicate)
        Description copied from interface: MenuNode
        Checks if this Menu node contains a menu node matching the given predicate
        Specified by:
        contains in interface MenuNode
        Parameters:
        predicate - the predicate to match
        Returns:
        boolean true if it contains a matching node, else false
      • firstItem

        public Optional<MenuItem> firstItem()
        Description copied from interface: MenuNode
        Finds the first menu item in this menu node. If it is a menu, this is the first item of its first child.
        Specified by:
        firstItem in interface MenuNode