Class BuildMenuEvent<T extends Menu>
java.lang.Object
com.foreach.across.modules.web.events.BuildMenuEvent<T>
- Type Parameters:
- T- Specific Menu implementation
- All Implemented Interfaces:
- AcrossEvent,- NamedAcrossEvent,- org.springframework.core.ResolvableTypeProvider
public class BuildMenuEvent<T extends Menu>
extends Object
implements NamedAcrossEvent, org.springframework.core.ResolvableTypeProvider
Event fired by the MenuFactory whenever a menu is being generated.  After menu generation, a menu will be sorted and the selector applied.
 Customizing the menu is usually done through the 
PathBasedMenuBuilder, updating a Menu after generation can be
 done by adding a post-processor. Post-processors will receive the generated, sorted menu with active items selected using the configured MenuSelector.- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionBuildMenuEvent(T menu) BuildMenuEvent(T menu, @NonNull PathBasedMenuBuilder menuBuilder, @NonNull org.springframework.core.ResolvableType menuResolvableType) BuildMenuEvent(T menu, PathBasedMenuBuilder menuBuilder) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddMenuPostProcessor(Consumer<T> postProcessor) builder()Get thePathBasedMenuBuilderbeing used for configuration of theMenu.Name for this event, same as the menu name.getMenu()The menu item that is being built.Name of the menu being built.The modifiable list of consumers that should be applied to the generatedMenubefore theMenuFactoryhands it out.Retrieve the menu selector that is attached to this event.org.springframework.core.ResolvableTypeRetrieve the item builder for a specific path, where the item should represent a group of items.booleanisForMenuOfType(@NonNull Class<? extends Menu> menuClass) Check if the current build event is for a menu of the given type.Retrieve the item builder for a specific path.optionalItem(String path) Return an item builder for updating an item if it exists.voidsetMenuSelector(MenuSelector menuSelector) Set theMenuSelectorthat should be used for selecting the active items, after theMenuhas been built by theMenuFactory.
- 
Constructor Details- 
BuildMenuEvent
 
- 
- 
Method Details- 
getResolvableTypepublic org.springframework.core.ResolvableType getResolvableType()- Specified by:
- getResolvableTypein interface- org.springframework.core.ResolvableTypeProvider
 
- 
getEventNameName for this event, same as the menu name.- Specified by:
- getEventNamein interface- NamedAcrossEvent
- Returns:
- event name
 
- 
getMenuNameName of the menu being built.- Returns:
- menu name
 
- 
getMenuSelectorRetrieve the menu selector that is attached to this event. A menu selector is optional, but when one is present it is expected to be used to select theMenuitem that is active. This is especially useful in a web request scenario where a single menu item represents the location of the current user web request. You can manually set the menu selector that theMenuFactoryshould use withsetMenuSelector(MenuSelector).- Returns:
- the MenuSelector attached to this event
- See Also:
 
- 
isForMenuOfTypeCheck if the current build event is for a menu of the given type.- Parameters:
- menuClass- expected type of menu
- Returns:
- true if menu is of that type
 
- 
itemRetrieve the item builder for a specific path. If there is none yet, one will be created. Short-hand forbuilder().item(path).- Parameters:
- path- identifying the item
- Returns:
- item builder
 
- 
groupRetrieve the item builder for a specific path, where the item should represent a group of items. If there is no item builder yet, one will be created. If the item builder exists, but is not yet flagged as a group, it will be turned into a group. Note that flagging an item as a group simply sets the appropriate property. It has no effect on the actualMenuhierarchy being built and the fact that this item might serve as a parent for others. The latter is purely determined by the path splitting when building the menu. Short-hand forbuilder().group(path).- Parameters:
- path- identifying the item
- Returns:
- item builder
 
- 
optionalItemReturn an item builder for updating an item if it exists. This will always return a valid item builder, but nothing will happen if that item did not exist before. Short-hand forbuilder().optionalItem(path).- Parameters:
- path- identifying the item
- Returns:
- item builder
 
- 
builderGet thePathBasedMenuBuilderbeing used for configuration of theMenu.- Returns:
- menu builder
- See Also:
 
- 
addMenuPostProcessorAdd a singleConsumerfor post-processing the generatedMenu. This consumer will be called once the menu has been generated, sorted and the selector applied; but before theMenuFactoryreturns to the caller.- Parameters:
- postProcessor- for the menu
 
- 
getMenuThe menu item that is being built. Usually you do not want to make direct changes to this menu but use thebuilder()instead. If you want to make modifications after the builder has been applied, register a custom post-processor usingaddMenuPostProcessor(Consumer).- Returns:
- menu being built - never null
 
- 
getMenuPostProcessorsThe modifiable list of consumers that should be applied to the generatedMenubefore theMenuFactoryhands it out.
 
-