]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/resolution/DependencyResult.java
Merge branch 'master' of https://github.com/argeo/argeo-slc.git
[gpl/argeo-slc.git] / org.argeo.slc.repo / src / org / eclipse / aether / resolution / DependencyResult.java
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
7 *
8 * Contributors:
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.aether.resolution;
12
13 import java.util.Collections;
14 import java.util.List;
15
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;
20
21 /**
22 * The result of a dependency resolution request.
23 *
24 * @see RepositorySystem#resolveDependencies(RepositorySystemSession, DependencyRequest)
25 */
26 public final class DependencyResult
27 {
28
29 private final DependencyRequest request;
30
31 private DependencyNode root;
32
33 private List<DependencyCycle> cycles;
34
35 private List<Exception> collectExceptions;
36
37 private List<ArtifactResult> artifactResults;
38
39 /**
40 * Creates a new result for the specified request.
41 *
42 * @param request The resolution request, must not be {@code null}.
43 */
44 public DependencyResult( DependencyRequest request )
45 {
46 if ( request == null )
47 {
48 throw new IllegalArgumentException( "dependency request has not been specified" );
49 }
50 this.request = request;
51 root = request.getRoot();
52 cycles = Collections.emptyList();
53 collectExceptions = Collections.emptyList();
54 artifactResults = Collections.emptyList();
55 }
56
57 /**
58 * Gets the resolution request that was made.
59 *
60 * @return The resolution request, never {@code null}.
61 */
62 public DependencyRequest getRequest()
63 {
64 return request;
65 }
66
67 /**
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.
70 *
71 * @return The root node of the resolved dependency graph or {@code null} if none.
72 */
73 public DependencyNode getRoot()
74 {
75 return root;
76 }
77
78 /**
79 * Sets the root node of the resolved dependency graph.
80 *
81 * @param root The root node of the resolved dependency graph, may be {@code null}.
82 * @return This result for chaining, never {@code null}.
83 */
84 public DependencyResult setRoot( DependencyNode root )
85 {
86 this.root = root;
87 return this;
88 }
89
90 /**
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.
95 *
96 * @return The dependency cycles in the (raw) graph, never {@code null}.
97 */
98 public List<DependencyCycle> getCycles()
99 {
100 return cycles;
101 }
102
103 /**
104 * Records the specified dependency cycles while building the dependency graph.
105 *
106 * @param cycles The dependency cycles to record, may be {@code null}.
107 * @return This result for chaining, never {@code null}.
108 */
109 public DependencyResult setCycles( List<DependencyCycle> cycles )
110 {
111 if ( cycles == null )
112 {
113 this.cycles = Collections.emptyList();
114 }
115 else
116 {
117 this.cycles = cycles;
118 }
119 return this;
120 }
121
122 /**
123 * Gets the exceptions that occurred while building the dependency graph.
124 *
125 * @return The exceptions that occurred, never {@code null}.
126 */
127 public List<Exception> getCollectExceptions()
128 {
129 return collectExceptions;
130 }
131
132 /**
133 * Records the specified exceptions while building the dependency graph.
134 *
135 * @param exceptions The exceptions to record, may be {@code null}.
136 * @return This result for chaining, never {@code null}.
137 */
138 public DependencyResult setCollectExceptions( List<Exception> exceptions )
139 {
140 if ( exceptions == null )
141 {
142 this.collectExceptions = Collections.emptyList();
143 }
144 else
145 {
146 this.collectExceptions = exceptions;
147 }
148 return this;
149 }
150
151 /**
152 * Gets the resolution results for the dependency artifacts that matched {@link DependencyRequest#getFilter()}.
153 *
154 * @return The resolution results for the dependency artifacts, never {@code null}.
155 */
156 public List<ArtifactResult> getArtifactResults()
157 {
158 return artifactResults;
159 }
160
161 /**
162 * Sets the resolution results for the artifacts that matched {@link DependencyRequest#getFilter()}.
163 *
164 * @param results The resolution results for the artifacts, may be {@code null}.
165 * @return This result for chaining, never {@code null}.
166 */
167 public DependencyResult setArtifactResults( List<ArtifactResult> results )
168 {
169 if ( results == null )
170 {
171 this.artifactResults = Collections.emptyList();
172 }
173 else
174 {
175 this.artifactResults = results;
176 }
177 return this;
178 }
179
180 @Override
181 public String toString()
182 {
183 return String.valueOf( artifactResults );
184 }
185
186 }