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.surefire.booter;
20  
21  import javax.annotation.Nonnull;
22  
23  import java.io.File;
24  import java.util.Collection;
25  import java.util.List;
26  
27  import static java.util.Collections.unmodifiableCollection;
28  import static java.util.Collections.unmodifiableList;
29  import static java.util.Objects.requireNonNull;
30  
31  /**
32   * Jigsaw class-path and module-path.
33   *
34   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
35   * @since 2.21.0.Jigsaw
36   */
37  public final class ModularClasspath {
38      private final String moduleNameFromDescriptor;
39      private final List<String> modulePath;
40      private final Collection<String> packages;
41      private final File patchFile;
42      private final boolean isMainDescriptor;
43  
44      public ModularClasspath(
45              @Nonnull String moduleNameFromDescriptor,
46              @Nonnull List<String> modulePath,
47              @Nonnull Collection<String> packages,
48              File patchFile,
49              boolean isMainDescriptor) {
50          this.moduleNameFromDescriptor = moduleNameFromDescriptor;
51          this.modulePath = modulePath;
52          this.packages = packages;
53          this.patchFile = isMainDescriptor ? requireNonNull(patchFile, "patchFile should not be null") : patchFile;
54          this.isMainDescriptor = isMainDescriptor;
55      }
56  
57      @Nonnull
58      public String getModuleNameFromDescriptor() {
59          return moduleNameFromDescriptor;
60      }
61  
62      @Nonnull
63      public List<String> getModulePath() {
64          return unmodifiableList(modulePath);
65      }
66  
67      @Nonnull
68      public Collection<String> getPackages() {
69          return unmodifiableCollection(packages);
70      }
71  
72      public File getPatchFile() {
73          return patchFile;
74      }
75  
76      public boolean isMainDescriptor() {
77          return isMainDescriptor;
78      }
79  }