Class DependencyNode
java.lang.Object
org.apache.maven.shared.dependency.tree.DependencyNode
Represents an artifact node within a Maven project's dependency tree.
- Version:
- $Id: DependencyNode.java 1595871 2014-05-19 12:38:45Z jvanzyl $
- Author:
- Edwin Punzalan, Mark Hobson
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
State that represents an included dependency node.static final int
State that represents a dependency node that has been omitted for conflicting with another dependency node.static final int
State that represents a dependency node that has been omitted for introducing a cycle into the dependency tree.static final int
State that represents a dependency node that has been omitted for duplicating another dependency node. -
Constructor Summary
ConstructorsConstructorDescriptionDependencyNode
(org.apache.maven.artifact.Artifact artifact) Creates a new dependency node for the specified artifact with an included state.DependencyNode
(org.apache.maven.artifact.Artifact artifact, int state) Creates a new dependency node for the specified artifact with the specified state.DependencyNode
(org.apache.maven.artifact.Artifact artifact, int state, org.apache.maven.artifact.Artifact relatedArtifact) Creates a new dependency node for the specified artifact with the specified state and related artifact. -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
(DependencyNodeVisitor visitor) Applies the specified dependency node visitor to this dependency node and its children.void
addChild
(DependencyNode child) Adds the specified dependency node to this dependency node's children.boolean
org.apache.maven.artifact.Artifact
Gets the artifact attached to this dependency node.List
<org.apache.maven.artifact.versioning.ArtifactVersion> If the version was selected from a range this method will return the available versions when making the decision.Gets the list of child dependency nodes of this dependency node.int
getDepth()
Deprecated.As of 1.1, depth is computed by node hierarchy.Gets the scope that this node's artifact was attempted to be updated to due to conflicts.Gets the scope of this node's artifact before it was updated due to conflicts.Gets the parent dependency node of this dependency node.Gets the scope of this node's artifact before it was updated by dependency management.Gets the version of this node's artifact before it was updated by dependency management.org.apache.maven.artifact.Artifact
Gets the artifact related to the state of this dependency node.int
getState()
Gets the state of this dependency node.org.apache.maven.artifact.versioning.VersionRange
If the version was selected from a range this method will return the range.boolean
int
hashCode()
Gets an iterator that returns this dependency node and it's children in postorder traversal.iterator()
Gets an iterator that returns this dependency node and it's children in preorder traversal.void
omitForConflict
(org.apache.maven.artifact.Artifact relatedArtifact) Changes the state of this dependency node to be omitted for conflict or duplication, depending on the specified related artifact.void
Changes the state of this dependency node to be omitted for a cycle in the dependency tree.Gets an iterator that returns this dependency node and it's children in preorder traversal.void
removeChild
(DependencyNode child) Removes the specified dependency node from this dependency node's children.void
setAvailableVersions
(List<org.apache.maven.artifact.versioning.ArtifactVersion> availableVersions) void
setFailedUpdateScope
(String failedUpdateScope) Sets the scope that this node's artifact was attempted to be updated to due to conflicts.void
setOriginalScope
(String originalScope) Sets the scope of this node's artifact before it was updated due to conflicts.void
setPremanagedScope
(String premanagedScope) Sets the scope of this node's artifact before it was updated by dependency management.void
setPremanagedVersion
(String premanagedVersion) Sets the version of this node's artifact before it was updated by dependency management.void
setVersionSelectedFromRange
(org.apache.maven.artifact.versioning.VersionRange versionSelectedFromRange) Returns a string representation of this dependency node.toString()
Returns a string representation of this dependency node and its children.toString
(int indentDepth) Deprecated.As of 1.1, replaced bytoString()
-
Field Details
-
INCLUDED
public static final int INCLUDEDState that represents an included dependency node.- Since:
- 1.1
- See Also:
-
OMITTED_FOR_DUPLICATE
public static final int OMITTED_FOR_DUPLICATEState that represents a dependency node that has been omitted for duplicating another dependency node.- Since:
- 1.1
- See Also:
-
OMITTED_FOR_CONFLICT
public static final int OMITTED_FOR_CONFLICTState that represents a dependency node that has been omitted for conflicting with another dependency node.- Since:
- 1.1
- See Also:
-
OMITTED_FOR_CYCLE
public static final int OMITTED_FOR_CYCLEState that represents a dependency node that has been omitted for introducing a cycle into the dependency tree.- Since:
- 1.1
- See Also:
-
-
Constructor Details
-
DependencyNode
public DependencyNode(org.apache.maven.artifact.Artifact artifact) Creates a new dependency node for the specified artifact with an included state.- Parameters:
artifact
- the artifact attached to the new dependency node- Throws:
IllegalArgumentException
- if the parameter constraints were violated- Since:
- 1.1
-
DependencyNode
public DependencyNode(org.apache.maven.artifact.Artifact artifact, int state) Creates a new dependency node for the specified artifact with the specified state.- Parameters:
artifact
- the artifact attached to the new dependency nodestate
- the state of the new dependency node. This can be eitherINCLUDED
orOMITTED_FOR_CYCLE
.- Throws:
IllegalArgumentException
- if the parameter constraints were violated- Since:
- 1.1
-
DependencyNode
public DependencyNode(org.apache.maven.artifact.Artifact artifact, int state, org.apache.maven.artifact.Artifact relatedArtifact) Creates a new dependency node for the specified artifact with the specified state and related artifact.- Parameters:
artifact
- the artifact attached to the new dependency nodestate
- the state of the new dependency node. This can be eitherINCLUDED
,OMITTED_FOR_DUPLICATE
,OMITTED_FOR_CONFLICT
orOMITTED_FOR_CYCLE
.relatedArtifact
- the artifact related to the state of this dependency node. For dependency nodes with a state ofOMITTED_FOR_DUPLICATE
orOMITTED_FOR_CONFLICT
, this represents the artifact that was conflicted with. For dependency nodes of other states, this should always benull
.- Throws:
IllegalArgumentException
- if the parameter constraints were violated- Since:
- 1.1
-
-
Method Details
-
getParent
Gets the parent dependency node of this dependency node.- Returns:
- the parent dependency node
-
getArtifact
public org.apache.maven.artifact.Artifact getArtifact()Gets the artifact attached to this dependency node.- Returns:
- the artifact
-
getDepth
public int getDepth()Deprecated.As of 1.1, depth is computed by node hierarchy. With the introduction of node visitors and filters this method can give misleading results. For example, consider serializing a tree with a filter using a visitor: this method would return the unfiltered depth of a node, whereas the correct depth would be calculated by the visitor.Gets the depth of this dependency node within its hierarchy.- Returns:
- the depth
-
getChildren
Gets the list of child dependency nodes of this dependency node.- Returns:
- the list of child dependency nodes
-
hasChildren
public boolean hasChildren() -
getState
public int getState()Gets the state of this dependency node.- Returns:
- the state: either
INCLUDED
,OMITTED_FOR_DUPLICATE
,OMITTED_FOR_CONFLICT
orOMITTED_FOR_CYCLE
. - Since:
- 1.1
-
getRelatedArtifact
public org.apache.maven.artifact.Artifact getRelatedArtifact()Gets the artifact related to the state of this dependency node. For dependency nodes with a state ofOMITTED_FOR_CONFLICT
, this represents the artifact that was conflicted with. For dependency nodes of other states, this is alwaysnull
.- Returns:
- the related artifact
- Since:
- 1.1
-
getOriginalScope
Gets the scope of this node's artifact before it was updated due to conflicts.- Returns:
- the original scope, or
null
if the artifact scope has not been updated - Since:
- 1.1
-
setOriginalScope
Sets the scope of this node's artifact before it was updated due to conflicts.- Parameters:
originalScope
- the original scope, ornull
if the artifact scope has not been updated- Since:
- 1.1
-
getFailedUpdateScope
Gets the scope that this node's artifact was attempted to be updated to due to conflicts.- Returns:
- the failed update scope, or
null
if the artifact scope has not failed being updated - Since:
- 1.1
-
setFailedUpdateScope
Sets the scope that this node's artifact was attempted to be updated to due to conflicts.- Parameters:
failedUpdateScope
- the failed update scope, ornull
if the artifact scope has not failed being updated- Since:
- 1.1
-
getPremanagedVersion
Gets the version of this node's artifact before it was updated by dependency management.- Returns:
- the premanaged version, or
null
if the artifact version has not been managed - Since:
- 1.1
-
setPremanagedVersion
Sets the version of this node's artifact before it was updated by dependency management.- Parameters:
premanagedVersion
- the premanaged version, ornull
if the artifact version has not been managed- Since:
- 1.1
-
getPremanagedScope
Gets the scope of this node's artifact before it was updated by dependency management.- Returns:
- the premanaged scope, or
null
if the artifact scope has not been managed - Since:
- 1.1
-
setPremanagedScope
Sets the scope of this node's artifact before it was updated by dependency management.- Parameters:
premanagedScope
- the premanaged scope, ornull
if the artifact scope has not been managed- Since:
- 1.1
-
getVersionSelectedFromRange
public org.apache.maven.artifact.versioning.VersionRange getVersionSelectedFromRange()If the version was selected from a range this method will return the range.- Returns:
- the version range before a version was selected, or
null
if the artifact had a explicit version. - Since:
- 1.2
-
setVersionSelectedFromRange
public void setVersionSelectedFromRange(org.apache.maven.artifact.versioning.VersionRange versionSelectedFromRange) -
getAvailableVersions
If the version was selected from a range this method will return the available versions when making the decision. -
setAvailableVersions
public void setAvailableVersions(List<org.apache.maven.artifact.versioning.ArtifactVersion> availableVersions) -
omitForConflict
public void omitForConflict(org.apache.maven.artifact.Artifact relatedArtifact) Changes the state of this dependency node to be omitted for conflict or duplication, depending on the specified related artifact.If the related artifact has a version equal to this dependency node's artifact, then this dependency node's state is changed to
OMITTED_FOR_DUPLICATE
, otherwise it is changed toOMITTED_FOR_CONFLICT
. Omitting this dependency node also removes all of its children.- Parameters:
relatedArtifact
- the artifact that this dependency node conflicted with- Throws:
IllegalStateException
- if this dependency node's state is notINCLUDED
IllegalArgumentException
- if the related artifact wasnull
or had a different dependency conflict id to this dependency node's artifact- Since:
- 1.1
- See Also:
-
omitForCycle
public void omitForCycle()Changes the state of this dependency node to be omitted for a cycle in the dependency tree.Omitting this node sets its state to
OMITTED_FOR_CYCLE
and removes all of its children.- Throws:
IllegalStateException
- if this dependency node's state is notINCLUDED
- Since:
- 1.1
- See Also:
-
iterator
Gets an iterator that returns this dependency node and it's children in preorder traversal.- Returns:
- the preorder traversal iterator
- See Also:
-
preorderIterator
Gets an iterator that returns this dependency node and it's children in preorder traversal.- Returns:
- the preorder traversal iterator
- See Also:
-
inverseIterator
Gets an iterator that returns this dependency node and it's children in postorder traversal.- Returns:
- the postorder traversal iterator
- See Also:
-
toNodeString
Returns a string representation of this dependency node.- Returns:
- the string representation
- Since:
- 1.1
- See Also:
-
toString
Deprecated.As of 1.1, replaced bytoString()
Returns a string representation of this dependency node and its children, indented to the specified depth.As of 1.1, this method ignores the indentation depth and simply delegates to
toString()
.- Parameters:
indentDepth
- the indentation depth- Returns:
- the string representation
-
hashCode
public int hashCode() -
equals
-
toString
Returns a string representation of this dependency node and its children.