View Javadoc
1   package org.apache.maven.surefire.booter;
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 javax.annotation.Nonnull;
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  {
39      private final String moduleNameFromDescriptor;
40      private final List<String> modulePath;
41      private final Collection<String> packages;
42      private final File patchFile;
43      private final boolean isMainDescriptor;
44  
45      public ModularClasspath( @Nonnull String moduleNameFromDescriptor,
46                               @Nonnull List<String> modulePath,
47                               @Nonnull Collection<String> packages,
48                               File patchFile,
49                               boolean isMainDescriptor )
50      {
51          this.moduleNameFromDescriptor = moduleNameFromDescriptor;
52          this.modulePath = modulePath;
53          this.packages = packages;
54          this.patchFile =
55              isMainDescriptor ? requireNonNull( patchFile, "patchFile should not be null" ) : patchFile;
56          this.isMainDescriptor = isMainDescriptor;
57      }
58  
59      @Nonnull
60      public String getModuleNameFromDescriptor()
61      {
62          return moduleNameFromDescriptor;
63      }
64  
65      @Nonnull
66      public List<String> getModulePath()
67      {
68          return unmodifiableList( modulePath );
69      }
70  
71      @Nonnull
72      public Collection<String> getPackages()
73      {
74          return unmodifiableCollection( packages );
75      }
76  
77      public File getPatchFile()
78      {
79          return patchFile;
80      }
81  
82      public boolean isMainDescriptor()
83      {
84          return isMainDescriptor;
85      }
86  }