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      /**
37       * Source of the modulename 
38       */
39      public enum ModuleNameSource
40      {
41          FILENAME, MANIFEST, MODULEDESCRIPTOR
42      }
43      
44      private JavaModuleDescriptor mainModuleDescriptor;
45      
46      /**
47       * Ordered map, respects the classpath order
48       */
49      private Map<T, JavaModuleDescriptor> pathElements;
50      
51      private Map<T, ModuleNameSource> modulepathElements = new LinkedHashMap<>();
52      
53      private Collection<T> classpathElements = new ArrayList<>();
54      
55      private Map<T, Exception> pathExceptions = new HashMap<>();
56  
57      void setMainModuleDescriptor( JavaModuleDescriptor mainModuleDescriptor )
58      {
59          this.mainModuleDescriptor = mainModuleDescriptor;
60      }
61  
62      /**
63       * The resolved main module descriptor  
64       * 
65       * @return the resolved descriptor 
66       * @see ResolvePathsRequest#setMainModuleDescriptor(Object)
67       */
68      public JavaModuleDescriptor getMainModuleDescriptor()
69      {
70          return mainModuleDescriptor;
71      }
72  
73      void setPathElements( Map<T, JavaModuleDescriptor> pathElements )
74      {
75          this.pathElements = pathElements;
76      }
77      
78      /**
79       * Ordered map, respects the classpath order
80       */
81      public Map<T, JavaModuleDescriptor> getPathElements()
82      {
83          return pathElements;
84      }
85      
86      void setClasspathElements( Collection<T> classpathElements )
87      {
88          this.classpathElements = classpathElements;
89      }
90      
91      /**
92       * All T that belong to the classpath based on the module descriptor
93       * 
94       * @return the classpath elements, never {@code null}
95       * @see #getPathElements()
96       */
97      public Collection<T> getClasspathElements()
98      {
99          return classpathElements;
100     }
101     
102     void setModulepathElements( Map<T, ModuleNameSource> modulepathElements )
103     {
104         this.modulepathElements = modulepathElements;
105     }
106     
107     /**
108      * All T that belong to the modulepath, based on the module descriptor.
109      * For every T the source for the module name is added. 
110      * 
111      * @return all modulepath elements, never {@code null} 
112      * @see #getPathElements()
113      */
114     public Map<T, ModuleNameSource> getModulepathElements()
115     {
116         return modulepathElements;
117     }
118 
119     void setPathExceptions( Map<T, Exception> pathExceptions )
120     {
121         this.pathExceptions = pathExceptions;
122     }
123 
124     /**
125      * Map containing exceptions for every T which modulename resolution failed
126      * 
127      * @return the exceptions for every T, never {@code null}
128      */
129     public Map<T, Exception> getPathExceptions()
130     {
131         return pathExceptions;
132     }
133 }