Class MenuItem

java.lang.Object
com.broadleafcommerce.menu.domain.MenuItem
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable
Direct Known Subclasses:
NavigableMenuItem

public class MenuItem extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
A domain representing a listed item in a menu tree.

Each menu item must be under a named Menu. Its position in the menu's hierarchy is entirely determined by the menu item which is specified as its parent.

Author:
Samarth Dhruva (samarthd)
See Also:
  • Constructor Details

    • MenuItem

      public MenuItem()
  • Method Details

    • getId

      public String getId()
      The context ID of the menu item.
      Returns:
      the context ID of the menu item
    • getParentMenuItemId

      public String getParentMenuItemId()
      The context ID of the menu item this menu item should be under.

      This is optional, as menu items don't have to be under another menu item. If this value is not set, this menu item will be a top level menu-item in its named menu.

      If this value is set, then this menu item will appear directly under the specified menu item, however deep that parent menu item is in the overall navigation tree.

      Returns:
      (optional) the context ID of the menu item this item should appear under
    • getParentMenuId

      public String getParentMenuId()
      The context ID of the named Menu this menu item should be under.

      This is required for all menu items regardless of whether they are top-level or deeply nested under other items.

      If the parent menu item is not set, then this item will appear in the first level of this specified named menu. Otherwise, it will only appear directly under that specified menu item in the tree of this menu.

      Returns:
      the context ID of the named menu whose tree this item should appear in
    • getLabel

      public String getLabel()
      The user-visible label for this menu item.
      Returns:
      the user-visible label for this menu item
    • getUrl

      public String getUrl()
      The url that is visited when the menu item is clicked.
      Returns:
      the url that is visited when the menu item is clicked
    • getDisplayOrder

      public Long getDisplayOrder()
      The order in which this item should be displayed relative to its siblings in the navigation tree.
      Returns:
      the order in which this item should be displayed relative to its siblings
    • getImageUrl

      public String getImageUrl()
      The url of the image that should be rendered (as an <img/>) when displaying this menu item.

      This field is optional.

      Returns:
      (optional) url of the image that should be rendered when displaying this menu item
      See Also:
    • getImageAltText

      public String getImageAltText()
      If imageUrl is set, this field should contain the alt text for that image.
      Returns:
      the alt text that should be used for the image (if set)
    • getCustomHtml

      public String getCustomHtml()
      The HTML that should be used to display the menu item.

      This field is optional, and is intended to enable customization of the display of the menu item.

      Returns:
      (optional) the HTML that should be used to display the menu item
    • getType

      public String getType()
      The type of menu item. For instance, this could be a link to a category, product, or CMS page.
      Returns:
      The type of menu item.
      See Also:
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • setId

      public void setId(String id)
      The context ID of the menu item.
      Parameters:
      id - the context ID of the menu item
    • setParentMenuItemId

      public void setParentMenuItemId(String parentMenuItemId)
      The context ID of the menu item this menu item should be under.

      This is optional, as menu items don't have to be under another menu item. If this value is not set, this menu item will be a top level menu-item in its named menu.

      If this value is set, then this menu item will appear directly under the specified menu item, however deep that parent menu item is in the overall navigation tree.

      Parameters:
      parentMenuItemId - (optional) the context ID of the menu item this item should appear under
    • setParentMenuId

      public void setParentMenuId(String parentMenuId)
      The context ID of the named Menu this menu item should be under.

      This is required for all menu items regardless of whether they are top-level or deeply nested under other items.

      If the parent menu item is not set, then this item will appear in the first level of this specified named menu. Otherwise, it will only appear directly under that specified menu item in the tree of this menu.

      Parameters:
      parentMenuId - the context ID of the named menu whose tree this item should appear in
    • setLabel

      public void setLabel(String label)
      The user-visible label for this menu item.
      Parameters:
      label - the user-visible label for this menu item
    • setUrl

      public void setUrl(String url)
      The url that is visited when the menu item is clicked.
      Parameters:
      url - the url that is visited when the menu item is clicked
    • setDisplayOrder

      public void setDisplayOrder(Long displayOrder)
      The order in which this item should be displayed relative to its siblings in the navigation tree.
      Parameters:
      displayOrder - the order in which this item should be displayed relative to its siblings
    • setImageUrl

      public void setImageUrl(String imageUrl)
      The url of the image that should be rendered (as an <img/>) when displaying this menu item.

      This field is optional.

      Parameters:
      imageUrl - (optional) url of the image that should be rendered when displaying this menu item
      See Also:
    • setImageAltText

      public void setImageAltText(String imageAltText)
      If imageUrl is set, this field should contain the alt text for that image.
      Parameters:
      imageAltText - the alt text that should be used for the image (if set)
    • setCustomHtml

      public void setCustomHtml(String customHtml)
      The HTML that should be used to display the menu item.

      This field is optional, and is intended to enable customization of the display of the menu item.

      Parameters:
      customHtml - (optional) the HTML that should be used to display the menu item
    • setType

      public void setType(String type)
      The type of menu item. For instance, this could be a link to a category, product, or CMS page.
      Parameters:
      type - The type of menu item.
      See Also:
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object