Interface NavGrouper

All Known Implementing Classes:
PathPrefixNavGrouper
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface NavGrouper
Strategy for mapping MenuEntry items to their position in the navigation tree. The returned NavNode encodes both the leaf and its full ancestor chain via NavNode.parent().

The default implementation is PathPrefixNavGrouper, which derives the hierarchy from route path segments.

Contract for implementors:

  • nodeFor(MenuEntry) must be idempotent: calling it multiple times with the same MenuEntry must return a node that is equal to the one returned on the first call. The framework calls nodeFor during both the initial nav build and on every subsequent navigation event (to resolve the active section for highlighting), so implementations that mutate state on the first call will produce incorrect results.
  • The order in which entries are passed to nodeFor is not guaranteed. Implementations that need a specific processing order (e.g. to register explicit group roots before path-based siblings) must handle that ordering internally, for example by lazily performing a full-population pass on the first call using MenuConfiguration.getMenuEntries().
  • Method Summary

    Modifier and Type
    Method
    Description
    nodeFor(com.vaadin.flow.server.menu.MenuEntry entry)
    Returns the NavNode representing entry in the navigation tree.
    default void
    Clears any cached state so the next nodeFor(MenuEntry) calls start fresh.
  • Method Details

    • nodeFor

      NavNode nodeFor(com.vaadin.flow.server.menu.MenuEntry entry)
      Returns the NavNode representing entry in the navigation tree. Set parent() on the returned node to encode group nesting; leave it absent for top-level items.

      Must be idempotent — see the class-level contract above.

    • reset

      default void reset()
      Clears any cached state so the next nodeFor(MenuEntry) calls start fresh.