Interface DependencyNode

  • All Known Implementing Classes:
    DefaultDependencyNode

    public interface DependencyNode
    A node within a dependency graph. To conserve memory, dependency graphs may reuse a given node instance multiple times to represent reoccurring dependencies. As such clients traversing a dependency graph should be prepared to discover multiple paths leading to the same node instance unless the input graph is known to be a duplicate-free tree. Note: Unless otherwise noted, implementation classes are not thread-safe and dependency nodes should not be mutated by concurrent threads.
    Restriction:
    This interface is not intended to be extended by clients.
    Restriction:
    This interface is not intended to be implemented by clients.
    • Method Detail

      • getChildren

        List<DependencyNodegetChildren()
        Gets the child nodes of this node. To conserve memory, dependency nodes with equal dependencies may share the same child list instance. Hence clients mutating the child list need to be aware that these changes might affect more than this node. Where this is not desired, the child list should be copied before mutation if the client cannot be sure whether it might be shared with other nodes in the graph.
        Returns:
        The child nodes of this node, never null.
      • setChildren

        void setChildren​(List<DependencyNode> children)
        Sets the child nodes of this node.
        Parameters:
        children - The child nodes, may be null
      • getDependency

        Dependency getDependency()
        Gets the dependency associated with this node. Note: For dependency graphs that have been constructed without a root dependency, this method will yield null when invoked on the graph's root node. The root node of such graphs may however still have a label as returned by getArtifact().
        Returns:
        The dependency or null if none.
      • getArtifact

        Artifact getArtifact()
        Gets the artifact associated with this node. If this node is associated with a dependency, this is equivalent to getDependency().getArtifact(). Otherwise the artifact merely provides a label for this node in which case the artifact must not be subjected to dependency collection/resolution.
        Returns:
        The associated artifact or null if none.
      • setArtifact

        void setArtifact​(Artifact artifact)
        Updates the artifact of the dependency after resolution. The new artifact must have the same coordinates as the original artifact. This method may only be invoked if this node actually has a dependency, i.e. if getDependency() is not null.
        Parameters:
        artifact - The artifact satisfying the dependency, must not be null.
      • getRelocations

        List<? extends ArtifactgetRelocations()
        Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.
        Returns:
        The (read-only) sequence of relocations, never null.
      • getAliases

        Collection<? extends ArtifactgetAliases()
        Gets the known aliases for this dependency's artifact. An alias can be used to mark a patched rebuild of some other artifact as such, thereby allowing conflict resolution to consider the patched and the original artifact as a conflict.
        Returns:
        The (read-only) set of known aliases, never null.
      • getVersionConstraint

        VersionConstraint getVersionConstraint()
        Gets the version constraint that was parsed from the dependency's version declaration.
        Returns:
        The version constraint for this node or null.
      • getVersion

        Version getVersion()
        Gets the version that was selected for the dependency's target artifact.
        Returns:
        The parsed version or null.
      • setScope

        void setScope​(String scope)
        Sets the scope of the dependency. This method may only be invoked if this node actually has a dependency, i.e. if getDependency() is not null.
        Parameters:
        scope - The scope, may be null.
      • setOptional

        void setOptional​(Boolean optional)
        Sets the optional flag of the dependency. This method may only be invoked if this node actually has a dependency, i.e. if getDependency() is not null.
        Parameters:
        optional - The optional flag, may be null.
      • getRepositories

        List<RemoteRepositorygetRepositories()
        Gets the remote repositories from which this node's artifact shall be resolved.
        Returns:
        The (read-only) list of remote repositories to use for artifact resolution, never null.
      • getRequestContext

        String getRequestContext()
        Gets the request context in which this dependency node was created.
        Returns:
        The request context, never null.
      • setRequestContext

        void setRequestContext​(String context)
        Sets the request context in which this dependency node was created.
        Parameters:
        context - The context, may be null.
      • getData

        Map<?,​?> getData()
        Gets the custom data associated with this dependency node. Clients of the repository system can use this data to annotate dependency nodes with domain-specific information. Note that the returned map is read-only and setData(Object, Object) needs to be used to update the custom data.
        Returns:
        The (read-only) key-value mappings, never null.
      • setData

        void setData​(Map<Object,​Object> data)
        Sets the custom data associated with this dependency node.
        Parameters:
        data - The new custom data, may be null.
      • setData

        void setData​(Object key,
                     Object value)
        Associates the specified dependency node data with the given key. Note: This method must not be called while getData() is being iterated.
        Parameters:
        key - The key under which to store the data, must not be null.
        value - The data to associate with the key, may be null to remove the mapping.
      • accept

        boolean accept​(DependencyVisitor visitor)
        Traverses this node and potentially its children using the specified visitor.
        Parameters:
        visitor - The visitor to call back, must not be null.
        Returns:
        true to visit siblings nodes of this node as well, false to skip siblings.