org.sonatype.aether.util.graph
Class DefaultDependencyNode

java.lang.Object
  extended by org.sonatype.aether.util.graph.DefaultDependencyNode
All Implemented Interfaces:
DependencyNode

public class DefaultDependencyNode
extends java.lang.Object
implements DependencyNode

A node within a dependency graph.

Author:
Benjamin Bentmann

Constructor Summary
DefaultDependencyNode()
          Creates an empty dependency node.
DefaultDependencyNode(Dependency dependency)
          Creates a new root node with the specified dependency.
DefaultDependencyNode(DependencyNode node)
          Creates a shallow clone of the specified node.
 
Method Summary
 boolean accept(DependencyVisitor visitor)
          Traverses this node and potentially its children using the specified visitor.
 java.util.Collection<Artifact> getAliases()
          Gets the known aliases for this dependency's artifact.
 java.util.List<DependencyNode> getChildren()
          Gets the child nodes of this node.
 Dependency getDependency()
          Gets the dependency associated with this node.
 java.lang.String getPremanagedScope()
          Gets the scope for the dependency before dependency management was applied (if any).
 java.lang.String getPremanagedVersion()
          Gets the version or version range for the dependency before dependency management was applied (if any).
 java.util.List<Artifact> getRelocations()
          Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.
 java.util.List<RemoteRepository> getRepositories()
          Gets the remote repositories from which this node's artifact shall be resolved.
 java.lang.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 setAliases(java.util.Collection<Artifact> aliases)
          Sets the known aliases for this dependency's artifact.
 void setArtifact(Artifact artifact)
          Sets the artifact of the dependency.
 void setDependency(Dependency dependency)
           
 void setPremanagedScope(java.lang.String premanagedScope)
          Sets the scope for this dependency before dependency management was applied (if any).
 void setPremanagedVersion(java.lang.String premanagedVersion)
          Sets the version or version range for this dependency before dependency management was applied (if any).
 void setRelocations(java.util.List<Artifact> relocations)
          Sets the sequence of relocations that was followed to resolve this dependency's artifact.
 void setRepositories(java.util.List<RemoteRepository> repositories)
          Sets the remote repositories from which this node's artifact shall be resolved.
 void setRequestContext(java.lang.String context)
          Sets the request context in which this dependency node was created.
 void setScope(java.lang.String scope)
          Sets the scope of the dependency.
 void setVersion(Version version)
           
 void setVersionConstraint(VersionConstraint versionConstraint)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDependencyNode

public DefaultDependencyNode()
Creates an empty dependency node.


DefaultDependencyNode

public DefaultDependencyNode(Dependency dependency)
Creates a new root node with the specified dependency.

Parameters:
dependency - The dependency associated with this node, may be null.

DefaultDependencyNode

public DefaultDependencyNode(DependencyNode node)
Creates a shallow clone of the specified node.

Parameters:
node - The node to copy, must not be null.
Method Detail

getChildren

public java.util.List<DependencyNode> getChildren()
Description copied from interface: DependencyNode
Gets the child nodes of this node.

Specified by:
getChildren in interface DependencyNode
Returns:
The child nodes of this node, never null.

getDependency

public Dependency getDependency()
Description copied from interface: DependencyNode
Gets the dependency associated with this node. Note: For dependency graphs that have been constructed without a root dependency, the root node will not have a dependency associated with it.

Specified by:
getDependency in interface DependencyNode
Returns:
The dependency or null if none.

setDependency

public void setDependency(Dependency dependency)

setArtifact

public void setArtifact(Artifact artifact)
Description copied from interface: DependencyNode
Sets the artifact of the dependency.

Specified by:
setArtifact in interface DependencyNode
Parameters:
artifact - The artifact satisfying the dependency, must not be null.

getRelocations

public java.util.List<Artifact> getRelocations()
Description copied from interface: DependencyNode
Gets the sequence of relocations that was followed to resolve the artifact referenced by the dependency.

Specified by:
getRelocations in interface DependencyNode
Returns:
The sequence of relocations, never null.

setRelocations

public void setRelocations(java.util.List<Artifact> relocations)
Sets the sequence of relocations that was followed to resolve this dependency's artifact.

Parameters:
relocations - The sequence of relocations, may be null.

getAliases

public java.util.Collection<Artifact> getAliases()
Description copied from interface: DependencyNode
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.

Specified by:
getAliases in interface DependencyNode
Returns:
The known aliases, never null.

setAliases

public void setAliases(java.util.Collection<Artifact> aliases)
Sets the known aliases for this dependency's artifact.

Parameters:
aliases - The known aliases, may be null.

getVersionConstraint

public VersionConstraint getVersionConstraint()
Description copied from interface: DependencyNode
Gets the version constraint that was parsed from the dependency's version declaration.

Specified by:
getVersionConstraint in interface DependencyNode
Returns:
The version constraint for this node or null.

setVersionConstraint

public void setVersionConstraint(VersionConstraint versionConstraint)

getVersion

public Version getVersion()
Description copied from interface: DependencyNode
Gets the version that was selected for the dependency's target artifact.

Specified by:
getVersion in interface DependencyNode
Returns:
The parsed version or null.

setVersion

public void setVersion(Version version)

setScope

public void setScope(java.lang.String scope)
Description copied from interface: DependencyNode
Sets the scope of the dependency.

Specified by:
setScope in interface DependencyNode
Parameters:
scope - The scope, may be null.

getPremanagedVersion

public java.lang.String getPremanagedVersion()
Description copied from interface: DependencyNode
Gets the version or version range for the dependency before dependency management was applied (if any).

Specified by:
getPremanagedVersion in interface DependencyNode
Returns:
The dependency version before dependency management or null if the version was not managed.

setPremanagedVersion

public void setPremanagedVersion(java.lang.String premanagedVersion)
Sets the version or version range for this dependency before dependency management was applied (if any).

Parameters:
premanagedVersion - The originally declared dependency version or null if the version was not managed.

getPremanagedScope

public java.lang.String getPremanagedScope()
Description copied from interface: DependencyNode
Gets the scope for the dependency before dependency management was applied (if any).

Specified by:
getPremanagedScope in interface DependencyNode
Returns:
The dependency scope before dependency management or null if the scope was not managed.

setPremanagedScope

public void setPremanagedScope(java.lang.String premanagedScope)
Sets the scope for this dependency before dependency management was applied (if any).

Parameters:
premanagedScope - The originally declared dependency scope or null if the scope was not managed.

getRepositories

public java.util.List<RemoteRepository> getRepositories()
Description copied from interface: DependencyNode
Gets the remote repositories from which this node's artifact shall be resolved.

Specified by:
getRepositories in interface DependencyNode
Returns:
The remote repositories to use for artifact resolution, never null.

setRepositories

public void setRepositories(java.util.List<RemoteRepository> repositories)
Sets the remote repositories from which this node's artifact shall be resolved.

Parameters:
repositories - The remote repositories to use for artifact resolution, may be null.

getRequestContext

public java.lang.String getRequestContext()
Description copied from interface: DependencyNode
Gets the request context in which this dependency node was created.

Specified by:
getRequestContext in interface DependencyNode
Returns:
The request context, never null.

setRequestContext

public void setRequestContext(java.lang.String context)
Description copied from interface: DependencyNode
Sets the request context in which this dependency node was created.

Specified by:
setRequestContext in interface DependencyNode
Parameters:
context - The context, may be null.

accept

public boolean accept(DependencyVisitor visitor)
Description copied from interface: DependencyNode
Traverses this node and potentially its children using the specified visitor.

Specified by:
accept in interface DependencyNode
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.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010 Sonatype, Inc.. All Rights Reserved.