Class DependencyTreeWalker.Matches<S>

java.lang.Object
org.openrewrite.maven.graph.DependencyTreeWalker.Matches<S>
Type Parameters:
S - the scope type (e.g., Maven Scope or Gradle configuration name String)
Enclosing class:
DependencyTreeWalker

public static class DependencyTreeWalker.Matches<S> extends Object
Collects dependency match information while walking the dependency tree. This collector builds two maps that track:
  • Which scopes/configurations contain direct dependencies that match or transitively depend on matches
  • Which target dependencies are reachable from each direct dependency

This is the pattern used by dependency insight recipes to mark direct dependencies based on their transitive dependencies.

  • Constructor Details

    • Matches

      public Matches()
  • Method Details

    • collect

      public void collect(S scope, ResolvedDependency root, org.openrewrite.semver.DependencyMatcher matcher, @Nullable DependencyTreeWalker.Callback callback)
      Walks the dependency tree for a given scope, collecting match mappings.
      Parameters:
      scope - the scope or configuration name
      root - the direct dependency to walk from
      matcher - the matcher to test dependencies against
      callback - optional callback for additional per-match processing (may be null)
    • byScope

      public Map<S,Set<GroupArtifactVersion>> byScope()
      Returns the mapping from scope to direct dependencies that have matching transitives.
    • byDirectDependency

      public Map<GroupArtifactVersion,Set<GroupArtifactVersion>> byDirectDependency()
      Returns the mapping from direct dependency to the transitive dependencies that matched.
    • isEmpty

      public boolean isEmpty()
      Returns true if no matches were found.