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