View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.project;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.IdentityHashMap;
24  import java.util.List;
25  import java.util.Map;
26  
27  import org.eclipse.aether.graph.Dependency;
28  import org.eclipse.aether.graph.DependencyNode;
29  
30  /**
31   */
32  class DefaultDependencyResolutionResult implements DependencyResolutionResult {
33  
34      private DependencyNode root;
35  
36      private List<Dependency> dependencies = new ArrayList<>();
37  
38      private List<Dependency> resolvedDependencies = new ArrayList<>();
39  
40      private List<Dependency> unresolvedDependencies = new ArrayList<>();
41  
42      private List<Exception> collectionErrors = new ArrayList<>();
43  
44      private Map<Dependency, List<Exception>> resolutionErrors = new IdentityHashMap<>();
45  
46      public DependencyNode getDependencyGraph() {
47          return root;
48      }
49  
50      public void setDependencyGraph(DependencyNode root) {
51          this.root = root;
52      }
53  
54      public List<Dependency> getDependencies() {
55          return dependencies;
56      }
57  
58      public List<Dependency> getResolvedDependencies() {
59          return resolvedDependencies;
60      }
61  
62      public void addResolvedDependency(Dependency dependency) {
63          dependencies.add(dependency);
64          resolvedDependencies.add(dependency);
65      }
66  
67      public List<Dependency> getUnresolvedDependencies() {
68          return unresolvedDependencies;
69      }
70  
71      public List<Exception> getCollectionErrors() {
72          return collectionErrors;
73      }
74  
75      public void setCollectionErrors(List<Exception> exceptions) {
76          if (exceptions != null) {
77              this.collectionErrors = exceptions;
78          } else {
79              this.collectionErrors = new ArrayList<>();
80          }
81      }
82  
83      public List<Exception> getResolutionErrors(Dependency dependency) {
84          List<Exception> errors = resolutionErrors.get(dependency);
85          return (errors != null) ? Collections.unmodifiableList(errors) : Collections.emptyList();
86      }
87  
88      public void setResolutionErrors(Dependency dependency, List<Exception> errors) {
89          dependencies.add(dependency);
90          unresolvedDependencies.add(dependency);
91          resolutionErrors.put(dependency, errors);
92      }
93  }