org.sonatype.aether.graph
Class Dependency

java.lang.Object
  extended by org.sonatype.aether.graph.Dependency

public final class Dependency
extends java.lang.Object

A dependency to some artifact. Note: Instances of this class are immutable and the exposed mutators return new objects rather than changing the current instance.

Author:
Benjamin Bentmann

Constructor Summary
Dependency(Artifact artifact, java.lang.String scope)
          Creates a mandatory dependency on the specified artifact with the given scope.
Dependency(Artifact artifact, java.lang.String scope, boolean optional)
          Creates a dependency on the specified artifact with the given scope.
Dependency(Artifact artifact, java.lang.String scope, boolean optional, java.util.Collection<Exclusion> exclusions)
          Creates a dependency on the specified artifact with the given scope and exclusions.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 Artifact getArtifact()
          Gets the artifact being depended on.
 java.util.Collection<Exclusion> getExclusions()
          Gets the exclusions for this dependency.
 java.lang.String getScope()
          Gets the scope of the dependency.
 int hashCode()
           
 boolean isOptional()
          Indicates whether this dependency is optional or not.
 Dependency setArtifact(Artifact artifact)
          Sets the artifact being depended on.
 Dependency setExclusions(java.util.Collection<Exclusion> exclusions)
          Sets the exclusions for the dependency.
 Dependency setOptional(boolean optional)
          Sets the optional flag for the dependency.
 Dependency setScope(java.lang.String scope)
          Sets the scope of the dependency, e.g.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dependency

public Dependency(Artifact artifact,
                  java.lang.String scope)
Creates a mandatory dependency on the specified artifact with the given scope.

Parameters:
artifact - The artifact being depended on, must not be null.
scope - The scope of the dependency, may be null.

Dependency

public Dependency(Artifact artifact,
                  java.lang.String scope,
                  boolean optional)
Creates a dependency on the specified artifact with the given scope.

Parameters:
artifact - The artifact being depended on, must not be null.
scope - The scope of the dependency, may be null.
optional - A flag whether the dependency is optional or mandatory.

Dependency

public Dependency(Artifact artifact,
                  java.lang.String scope,
                  boolean optional,
                  java.util.Collection<Exclusion> exclusions)
Creates a dependency on the specified artifact with the given scope and exclusions.

Parameters:
artifact - The artifact being depended on, must not be null.
scope - The scope of the dependency, may be null.
optional - A flag whether the dependency is optional or mandatory.
exclusions - The exclusions that apply to transitive dependencies, may be null if none.
Method Detail

getArtifact

public Artifact getArtifact()
Gets the artifact being depended on.

Returns:
The artifact, never null.

setArtifact

public Dependency setArtifact(Artifact artifact)
Sets the artifact being depended on.

Parameters:
artifact - The artifact, must not be null.
Returns:
The new dependency, never null.

getScope

public java.lang.String getScope()
Gets the scope of the dependency. The scope defines in which context this dependency is relevant.

Returns:
The scope or an empty string if not set, never null.

setScope

public Dependency setScope(java.lang.String scope)
Sets the scope of the dependency, e.g. "compile".

Parameters:
scope - The scope of the dependency, may be null.
Returns:
The new dependency, never null.

isOptional

public boolean isOptional()
Indicates whether this dependency is optional or not. Optional dependencies can usually be ignored during transitive dependency resolution.

Returns:
true if the dependency is optional, false otherwise.

setOptional

public Dependency setOptional(boolean optional)
Sets the optional flag for the dependency.

Parameters:
optional - true if the dependency is optional, false if the dependency is mandatory.
Returns:
The new dependency, never null.

getExclusions

public java.util.Collection<Exclusion> getExclusions()
Gets the exclusions for this dependency. Exclusions can be used to remove transitive dependencies during resolution.

Returns:
The (read-only) exclusions, never null.

setExclusions

public Dependency setExclusions(java.util.Collection<Exclusion> exclusions)
Sets the exclusions for the dependency.

Parameters:
exclusions - The exclusions, may be null.
Returns:
The new dependency, never null.

toString

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


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