Package org.eclipse.aether.graph
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.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MANAGED_EXCLUSIONS
A bit flag indicating the exclusions were subject to dependency managementstatic int
MANAGED_OPTIONAL
A bit flag indicating the optional flag was subject to dependency managementstatic int
MANAGED_PROPERTIES
A bit flag indicating the artifact properties were subject to dependency managementstatic int
MANAGED_SCOPE
A bit flag indicating the dependency scope was subject to dependency managementstatic int
MANAGED_VERSION
A bit flag indicating the dependency version was subject to dependency management
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
accept(DependencyVisitor visitor)
Traverses this node and potentially its children using the specified visitor.Collection<? extends Artifact>
getAliases()
Gets the known aliases for this dependency's artifact.Artifact
getArtifact()
Gets the artifact associated with this node.List<DependencyNode>
getChildren()
Gets the child nodes of this node.Map<?,?>
getData()
Gets the custom data associated with this dependency node.Dependency
getDependency()
Gets the dependency associated with this node.int
getManagedBits()
Gets a bit field indicating which attributes of this node were subject to dependency management.List<? extends Artifact>
getRelocations()
Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.List<RemoteRepository>
getRepositories()
Gets the remote repositories from which this node's artifact shall be resolved.String
getRequestContext()
Gets the request context in which this dependency node was created.Version
getVersion()
Gets the version that was selected for the dependency's target artifact.VersionConstraint
getVersionConstraint()
Gets the version constraint that was parsed from the dependency's version declaration.void
setArtifact(Artifact artifact)
Updates the artifact of the dependency after resolution.void
setChildren(List<DependencyNode> children)
Sets the child nodes of this node.void
setData(Object key, Object value)
Associates the specified dependency node data with the given key.void
setData(Map<Object,Object> data)
Sets the custom data associated with this dependency node.void
setOptional(Boolean optional)
Sets the optional flag of the dependency.void
setRequestContext(String context)
Sets the request context in which this dependency node was created.void
setScope(String scope)
Sets the scope of the dependency.
-
-
-
Field Detail
-
MANAGED_VERSION
static final int MANAGED_VERSION
A bit flag indicating the dependency version was subject to dependency management- See Also:
getManagedBits()
, Constant Field Values
-
MANAGED_SCOPE
static final int MANAGED_SCOPE
A bit flag indicating the dependency scope was subject to dependency management- See Also:
getManagedBits()
, Constant Field Values
-
MANAGED_OPTIONAL
static final int MANAGED_OPTIONAL
A bit flag indicating the optional flag was subject to dependency management- See Also:
getManagedBits()
, Constant Field Values
-
MANAGED_PROPERTIES
static final int MANAGED_PROPERTIES
A bit flag indicating the artifact properties were subject to dependency management- See Also:
getManagedBits()
, Constant Field Values
-
MANAGED_EXCLUSIONS
static final int MANAGED_EXCLUSIONS
A bit flag indicating the exclusions were subject to dependency management- See Also:
getManagedBits()
, Constant Field Values
-
-
Method Detail
-
getChildren
List<DependencyNode> getChildren()
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 benull
-
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 yieldnull
when invoked on the graph's root node. The root node of such graphs may however still have a label as returned bygetArtifact()
.- 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 togetDependency().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. ifgetDependency()
is not null.- Parameters:
artifact
- The artifact satisfying the dependency, must not benull
.
-
getRelocations
List<? extends Artifact> getRelocations()
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 Artifact> getAliases()
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. ifgetDependency()
is not null.- Parameters:
scope
- The scope, may benull
.
-
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. ifgetDependency()
is not null.- Parameters:
optional
- The optional flag, may benull
.
-
getManagedBits
int getManagedBits()
Gets a bit field indicating which attributes of this node were subject to dependency management.- Returns:
- A bit field containing any of the bits
MANAGED_VERSION
,MANAGED_SCOPE
,MANAGED_OPTIONAL
,MANAGED_PROPERTIES
andMANAGED_EXCLUSIONS
if the corresponding attribute was set via dependency management.
-
getRepositories
List<RemoteRepository> getRepositories()
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 benull
.
-
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 andsetData(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 benull
.
-
setData
void setData(Object key, Object value)
Associates the specified dependency node data with the given key. Note: This method must not be called whilegetData()
is being iterated.- Parameters:
key
- The key under which to store the data, must not benull
.value
- The data to associate with the key, may benull
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 benull
.- Returns:
true
to visit siblings nodes of this node as well,false
to skip siblings.
-
-