Class QMenuItemSubMenu

java.lang.Object
com.kingsrook.qqq.backend.core.model.metadata.menus.items.QMenuItemBase
com.kingsrook.qqq.backend.core.model.metadata.menus.items.QMenuItemSubMenu
All Implemented Interfaces:
QMenuItemInterface, QMenuItemContainerInterface, QMetaDataObject, Serializable, Cloneable

public class QMenuItemSubMenu extends QMenuItemBase implements QMenuItemContainerInterface
Menu item that contains a nested sub-menu of other menu items.

Sub-menus are used to create hierarchical menu structures. They differ from sub-lists in that they typically render as a nested menu that opens when selected, rather than displaying items inline. Sub-menus are useful for organizing large numbers of menu items into logical groups for users to see.

This class implements QMenuItemContainerInterface to allow it to contain other menu items. Sub-menus can have their own label and icon, which are displayed in the parent menu.

See Also:
  • Constructor Details

    • QMenuItemSubMenu

      public QMenuItemSubMenu()
  • Method Details

    • getItemType

      public String getItemType()
      Returns the item type identifier for sub-menu menu items.
      Specified by:
      getItemType in interface QMenuItemInterface
      Returns:
      always returns "SUB_MENU"
    • getValues

      public Map<String,Serializable> getValues()
      Returns the values map containing the list of items in this sub-menu.
      Specified by:
      getValues in interface QMenuItemInterface
      Returns:
      a map containing the items list under the key "items"
    • validate

      public void validate(QInstanceValidator validator, QInstance qInstance, QMetaDataObject parentObject)
      Validates all menu items contained within this sub-menu.

      Recursively validates each item in the sub-menu, passing this sub-menu as the parent object for validation context.

      Specified by:
      validate in interface QMenuItemInterface
      Parameters:
      validator - the validator instance to use for reporting errors
      qInstance - the QQQ instance being validated
      parentObject - the parent metadata object containing this sub-menu
    • withLabel

      public QMenuItemSubMenu withLabel(String label)
      Fluent setter for label that returns this sub-menu for method chaining.
      Overrides:
      withLabel in class QMenuItemBase
      Parameters:
      label - user-facing text to display as the label for this sub-menu
      Returns:
      this sub-menu instance
    • withIcon

      public QMenuItemSubMenu withIcon(QIcon icon)
      Fluent setter for icon that returns this sub-menu for method chaining.
      Overrides:
      withIcon in class QMenuItemBase
      Parameters:
      icon - optional icon to display with this sub-menu
      Returns:
      this sub-menu instance
    • getItems

      public List<QMenuItemInterface> getItems()
      Getter for items
      Specified by:
      getItems in interface QMenuItemContainerInterface
      Returns:
      the list of menu items, which may be empty but should not be null
      See Also:
    • setItems

      public void setItems(List<QMenuItemInterface> items)
      Setter for items
      See Also:
    • withItems

      public QMenuItemSubMenu withItems(List<QMenuItemInterface> items)
      Fluent setter for items
      Parameters:
      items - Contents of the sub Menu
      Returns:
      this
    • withItem

      public QMenuItemSubMenu withItem(QMenuItemInterface item)
      Fluently add a single item
      Parameters:
      item - one item to add to this sub Menu
      Returns:
      this
    • clone

      public QMenuItemSubList clone()
      Creates and returns a deep copy of this sub-menu menu item.

      The cloned sub-menu will have its own copy of the items list, with each item also being cloned. This ensures that modifications to the cloned sub-menu or its items will not affect the original.

      Specified by:
      clone in interface QMenuItemInterface
      Overrides:
      clone in class QMenuItemBase
      Returns:
      a deep clone of this sub-menu menu item