Skip to content

feat: add RouteHierarchy walker#24446

Closed
web-padawan wants to merge 1 commit into
feat/route-parent-annotationfrom
feat/route-hierarchy-walker
Closed

feat: add RouteHierarchy walker#24446
web-padawan wants to merge 1 commit into
feat/route-parent-annotationfrom
feat/route-hierarchy-walker

Conversation

@web-padawan

@web-padawan web-padawan commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Adds com.vaadin.flow.router.RouteHierarchy — walks ancestor routes
for a given @Route class, consulting @RouteParent first and falling
back to URL-prefix walking. Cycle-safe.

Stacked on #24444 (adds @RouteParent). That PR should land first;
GitHub will auto-retarget this PR to main once it merges.

Test plan

  • mvn -pl flow-server test -Dtest=RouteHierarchyTest (14 cases)
  • Reviewer sanity-checks the algorithm against the breadcrumbs
    flow-spec.md Step 3 contract

🤖 Generated with Claude Code

Introduces com.vaadin.flow.router.RouteHierarchy with resolveAncestors
and resolveParent. Consumes @RouteParent first, falls back to
URL-prefix walking via RouteConfiguration#getTemplate /
#getRoute. Cycle-safe via a visited set.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@tltv tltv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that other PR added also Entry record and parameter support. Entry can be extracted to RouteHierarchyEntry record. Public resolveAncestors methods can go to RouteConfiguration, rest to RouteUtil.

* @see RouteParent
* @see RouteConfiguration
*/
public static List<Class<? extends Component>> resolveAncestors(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to RouteConfiguration class and change to non-static and remove routeConfiguration parameter.

* @see RouteParent
* @see RouteConfiguration
*/
public static Optional<Class<? extends Component>> resolveParent(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to RouteUtil.

* present are rejected to avoid cycles
* @return the parent class, or empty when no parent can be resolved
*/
private static Optional<Class<? extends Component>> findParent(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to RouteUtil.

* @see RouteParent
* @see RouteConfiguration
*/
public final class RouteHierarchy {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If everything will be moved out, remove RouteHierarchy.

@web-padawan

Copy link
Copy Markdown
Member Author

Closing in favor of #24550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants