View Javadoc

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