Class ScopeDependencySelector

  • All Implemented Interfaces:
    DependencySelector

    public final class ScopeDependencySelector
    extends Object
    implements DependencySelector
    A dependency selector that filters transitive dependencies based on their scope. Direct dependencies are always included regardless of their scope. Note: This filter does not assume any relationships between the scopes. In particular, the filter is not aware of scopes that logically include other scopes.
    See Also:
    Dependency.getScope()
    • Constructor Detail

      • ScopeDependencySelector

        public ScopeDependencySelector​(Collection<String> included,
                                       Collection<String> excluded)
        Creates a new selector using the specified includes and excludes.
        Parameters:
        included - The set of scopes to include, may be null or empty to include any scope.
        excluded - The set of scopes to exclude, may be null or empty to exclude no scope.
      • ScopeDependencySelector

        public ScopeDependencySelector​(String... excluded)
        Creates a new selector using the specified excludes.
        Parameters:
        excluded - The set of scopes to exclude, may be null or empty to exclude no scope.
    • Method Detail

      • selectDependency

        public boolean selectDependency​(Dependency dependency)
        Description copied from interface: DependencySelector
        Decides whether the specified dependency should be included in the dependency graph.
        Specified by:
        selectDependency in interface DependencySelector
        Parameters:
        dependency - The dependency to check, must not be null.
        Returns:
        false if the dependency should be excluded from the children of the current node, true otherwise.
      • deriveChildSelector

        public DependencySelector deriveChildSelector​(DependencyCollectionContext context)
        Description copied from interface: DependencySelector
        Derives a dependency selector for the specified collection context. When calculating the child selector, implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
        Specified by:
        deriveChildSelector in interface DependencySelector
        Parameters:
        context - The dependency collection context, must not be null.
        Returns:
        The dependency selector for the target node or null if dependencies should be unconditionally included in the sub graph.