Class PathBasedMenuBuilder.PathBasedMenuItemBuilder
java.lang.Object
com.foreach.across.modules.web.menu.PathBasedMenuBuilder.PathBasedMenuItemBuilder
- All Implemented Interfaces:
Comparable<PathBasedMenuBuilder.PathBasedMenuItemBuilder>
- Enclosing class:
- PathBasedMenuBuilder
public static final class PathBasedMenuBuilder.PathBasedMenuItemBuilder
extends Object
implements Comparable<PathBasedMenuBuilder.PathBasedMenuItemBuilder>
Represents a single item builder attached to a parent
PathBasedMenuBuilder
.-
Method Summary
Modifier and TypeMethodDescriptionand()
Go up a level, switch from the item builder back to the menu builder.Apply an attribute registrar to the collection of attributes for this menu item.Add a single attribute to this menu item.changePathTo
(@NonNull String newPath) Change the path of this menu item, as well as all other items that have the current path as a prefix.changePathTo
(@NonNull String newPath, boolean replaceAllItemsWithPrefix) Change the path of this menu item, optionally changing other items that have the current path as a prefix.comparator
(Comparator<Menu> comparator, boolean inheritable) Set the comparator to be used when sorting the children of this menu item.int
disable()
Flag this menu item as disabled.disable
(boolean status) Flag this menu item as disabled or enabled.enable()
Flag this menu item as enabled.enable
(boolean status) Flag this menu item as disabled or enabled.boolean
group
(boolean group) Set the 'group' flag on the menu item.int
hashCode()
matchRequests
(String... matchers) Add prefix strings on which this menu item will match in case aRequestMenuSelector
is being used.Add one or more option attributes to this menu item.order
(int order) Set the order of this menu item.remove
(boolean removeAllItemsWithPrefix) Remove this item.removeAttributes
(String... keys) Remove the attributes with the given keys.Set the title for this menu item.toString()
Set the url for this menu item.
-
Method Details
-
comparator
public PathBasedMenuBuilder.PathBasedMenuItemBuilder comparator(Comparator<Menu> comparator, boolean inheritable) Set the comparator to be used when sorting the children of this menu item. If the comparator is inheritable, it will also be used for the sub-menus in the resulting tree, unless they have another comparator set explicitly. Note that depending on the custom comparator you set, the value oforder(int)
might be ignored.- Parameters:
comparator
- to useinheritable
- should the comparator also apply to any resulting sub-menus of this item- Returns:
- current builder
-
order
Set the order of this menu item.- Returns:
- current item builder
-
disable
Flag this menu item as disabled.- Returns:
- current item builder
-
enable
Flag this menu item as enabled.- Returns:
- current item builder
-
disable
Flag this menu item as disabled or enabled.- Parameters:
status
- disabled or not- Returns:
- current item builder
-
enable
Flag this menu item as disabled or enabled.- Parameters:
status
- enabled or not- Returns:
- current item builder
-
attribute
Add a single attribute to this menu item.- Parameters:
key
- attribute keyvalue
- attribute value- Returns:
- current item builder
-
attribute
public PathBasedMenuBuilder.PathBasedMenuItemBuilder attribute(@NonNull @NonNull Consumer<Map<String, Object>> attributeRegistrar) Apply an attribute registrar to the collection of attributes for this menu item.- Parameters:
attributeRegistrar
- to execute- Returns:
- current item builder
-
options
Add one or more option attributes to this menu item. An option attribute is an attribute where the key is identical to the value. For every argument X, an attribute with key X and value X will be added.- Parameters:
options
- to add- Returns:
- current item builder
-
removeAttributes
Remove the attributes with the given keys.- Parameters:
keys
- of the attributes to remove- Returns:
- current item builder
-
matchRequests
Add prefix strings on which this menu item will match in case aRequestMenuSelector
is being used. If the request starts with any of these prefixes, this menu item will be selected.These values only apply if the selector supports it. This is usually the case for menus being built through the
MenuFactory
using aRequestMenuBuilder
behind the scened.- Parameters:
matchers
- one or more prefix strings- See Also:
-
remove
Remove this item. Optionally removing all other items with this path as prefix. This method returns the menu builder that this item belonged to, destroying the item builder.- Parameters:
removeAllItemsWithPrefix
- true if all other items having this prefix should also be removed- Returns:
- menu builder
-
changePathTo
Change the path of this menu item, as well as all other items that have the current path as a prefix. This path change will happen immediately and after this call a new item can be created on the previous path. If you only want to change the path of the current item but not all other items starting with this path, usechangePathTo("new path", false)
.- Parameters:
newPath
- new path that should be used- Returns:
- current item builder
- See Also:
-
changePathTo
public PathBasedMenuBuilder.PathBasedMenuItemBuilder changePathTo(@NonNull @NonNull String newPath, boolean replaceAllItemsWithPrefix) Change the path of this menu item, optionally changing other items that have the current path as a prefix. This path change will happen immediately and after this call a new item can be created on the previous path.- Parameters:
newPath
- new path that should be usedreplaceAllItemsWithPrefix
- false if only the current item should have its path changed- Returns:
- current item builder
- See Also:
-
and
Go up a level, switch from the item builder back to the menu builder.- Returns:
- menu builder this item belongs to
-
equals
-
hashCode
public int hashCode() -
toString
-
group
Set the 'group' flag on the menu item.- Returns:
this
.
-
title
Set the title for this menu item.- Returns:
this
.
-
url
Set the url for this menu item.- Returns:
this
.
-