View Javadoc
1   package org.codehaus.plexus.languages.java.jpms;
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.Collection;
24  import java.util.HashMap;
25  import java.util.LinkedHashMap;
26  import java.util.Map;
27  
28  /**
29   * Holds the results of the project analyzer
30   * 
31   * @author Robert Scholte
32   * @since 1.0.0
33   */
34  public class ResolvePathsResult<T>
35  {
36      private JavaModuleDescriptor mainModuleDescriptor;
37      
38      /**
39       * Ordered map, respects the classpath order
40       */
41      private Map<T, JavaModuleDescriptor> pathElements;
42      
43      private Map<T, ModuleNameSource> modulepathElements = new LinkedHashMap<>();
44      
45      private Collection<T> classpathElements = new ArrayList<>();
46      
47      private Map<T, Exception> pathExceptions = new HashMap<>();
48  
49      void setMainModuleDescriptor( JavaModuleDescriptor mainModuleDescriptor )
50      {
51          this.mainModuleDescriptor = mainModuleDescriptor;
52      }
53  
54      /**
55       * The resolved main module descriptor  
56       * 
57       * @return the resolved descriptor 
58       * @see ResolvePathsRequest#setMainModuleDescriptor(Object)
59       */
60      public JavaModuleDescriptor getMainModuleDescriptor()
61      {
62          return mainModuleDescriptor;
63      }
64  
65      void setPathElements( Map<T, JavaModuleDescriptor> pathElements )
66      {
67          this.pathElements = pathElements;
68      }
69      
70      /**
71       * Ordered map, respects the classpath order
72       */
73      public Map<T, JavaModuleDescriptor> getPathElements()
74      {
75          return pathElements;
76      }
77      
78      void setClasspathElements( Collection<T> classpathElements )
79      {
80          this.classpathElements = classpathElements;
81      }
82      
83      /**
84       * All T that belong to the classpath based on the module descriptor
85       * 
86       * @return the classpath elements, never {@code null}
87       * @see #getPathElements()
88       */
89      public Collection<T> getClasspathElements()
90      {
91          return classpathElements;
92      }
93      
94      void setModulepathElements( Map<T, ModuleNameSource> modulepathElements )
95      {
96          this.modulepathElements = modulepathElements;
97      }
98      
99      /**
100      * All T that belong to the modulepath, based on the module descriptor.
101      * For every T the source for the module name is added. 
102      * 
103      * @return all modulepath elements, never {@code null} 
104      * @see #getPathElements()
105      */
106     public Map<T, ModuleNameSource> getModulepathElements()
107     {
108         return modulepathElements;
109     }
110 
111     void setPathExceptions( Map<T, Exception> pathExceptions )
112     {
113         this.pathExceptions = pathExceptions;
114     }
115 
116     /**
117      * Map containing exceptions for every T which modulename resolution failed
118      * 
119      * @return the exceptions for every T, never {@code null}
120      */
121     public Map<T, Exception> getPathExceptions()
122     {
123         return pathExceptions;
124     }
125 }