1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.resolution
;
13 import java
.util
.Collections
;
14 import java
.util
.List
;
16 import org
.eclipse
.aether
.RepositorySystem
;
17 import org
.eclipse
.aether
.RepositorySystemSession
;
18 import org
.eclipse
.aether
.graph
.DependencyCycle
;
19 import org
.eclipse
.aether
.graph
.DependencyNode
;
22 * The result of a dependency resolution request.
24 * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
26 public final class DependencyResult
29 private final DependencyRequest request
;
31 private DependencyNode root
;
33 private List
<DependencyCycle
> cycles
;
35 private List
<Exception
> collectExceptions
;
37 private List
<ArtifactResult
> artifactResults
;
40 * Creates a new result for the specified request.
42 * @param request The resolution request, must not be {@code null}.
44 public DependencyResult( DependencyRequest request
)
46 if ( request
== null )
48 throw new IllegalArgumentException( "dependency request has not been specified" );
50 this.request
= request
;
51 root
= request
.getRoot();
52 cycles
= Collections
.emptyList();
53 collectExceptions
= Collections
.emptyList();
54 artifactResults
= Collections
.emptyList();
58 * Gets the resolution request that was made.
60 * @return The resolution request, never {@code null}.
62 public DependencyRequest
getRequest()
68 * Gets the root node of the resolved dependency graph. Note that this dependency graph might be
69 * incomplete/unfinished in case of {@link #getCollectExceptions()} indicating errors during its calculation.
71 * @return The root node of the resolved dependency graph or {@code null} if none.
73 public DependencyNode
getRoot()
79 * Sets the root node of the resolved dependency graph.
81 * @param root The root node of the resolved dependency graph, may be {@code null}.
82 * @return This result for chaining, never {@code null}.
84 public DependencyResult
setRoot( DependencyNode root
)
91 * Gets the dependency cycles that were encountered while building the dependency graph. Note that dependency cycles
92 * will only be reported here if the underlying request was created from a
93 * {@link org.eclipse.aether.collection.CollectRequest CollectRequest}. If the underlying {@link DependencyRequest}
94 * was created from an existing dependency graph, information about cycles will not be available in this result.
96 * @return The dependency cycles in the (raw) graph, never {@code null}.
98 public List
<DependencyCycle
> getCycles()
104 * Records the specified dependency cycles while building the dependency graph.
106 * @param cycles The dependency cycles to record, may be {@code null}.
107 * @return This result for chaining, never {@code null}.
109 public DependencyResult
setCycles( List
<DependencyCycle
> cycles
)
111 if ( cycles
== null )
113 this.cycles
= Collections
.emptyList();
117 this.cycles
= cycles
;
123 * Gets the exceptions that occurred while building the dependency graph.
125 * @return The exceptions that occurred, never {@code null}.
127 public List
<Exception
> getCollectExceptions()
129 return collectExceptions
;
133 * Records the specified exceptions while building the dependency graph.
135 * @param exceptions The exceptions to record, may be {@code null}.
136 * @return This result for chaining, never {@code null}.
138 public DependencyResult
setCollectExceptions( List
<Exception
> exceptions
)
140 if ( exceptions
== null )
142 this.collectExceptions
= Collections
.emptyList();
146 this.collectExceptions
= exceptions
;
152 * Gets the resolution results for the dependency artifacts that matched {@link DependencyRequest#getFilter()}.
154 * @return The resolution results for the dependency artifacts, never {@code null}.
156 public List
<ArtifactResult
> getArtifactResults()
158 return artifactResults
;
162 * Sets the resolution results for the artifacts that matched {@link DependencyRequest#getFilter()}.
164 * @param results The resolution results for the artifacts, may be {@code null}.
165 * @return This result for chaining, never {@code null}.
167 public DependencyResult
setArtifactResults( List
<ArtifactResult
> results
)
169 if ( results
== null )
171 this.artifactResults
= Collections
.emptyList();
175 this.artifactResults
= results
;
181 public String
toString()
183 return String
.valueOf( artifactResults
);