1   package org.apache.maven.plugin.compiler.module;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  import java.util.Collections;
23  import java.util.HashSet;
24  import java.util.Set;
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  public class JavaModuleDescriptor
35  {
36      private String name;
37      
38      private boolean automatic;
39  
40      private Set<JavaRequires> requires = new HashSet<JavaRequires>();
41      
42      private Set<JavaExports> exports = new HashSet<JavaExports>();
43  
44      public String name()
45      {
46          return name;
47      }
48  
49      public boolean isAutomatic()
50      {
51          return automatic;
52      }
53      
54      public Set<JavaRequires> requires()
55      {
56          return Collections.unmodifiableSet( requires );
57      }
58      
59      public Set<JavaExports> exports()
60      {
61          return Collections.unmodifiableSet( exports );
62      }
63      
64      public static JavaModuleDescriptor.Builder newModule( String name )
65      {
66          return new Builder( name ).setAutomatic( false );
67      }
68      
69      public static Builder newAutomaticModule( String name )
70      {
71          return new Builder( name ).setAutomatic( true );
72      }  
73  
74      
75  
76  
77  
78  
79  
80      public static final class Builder
81      {
82          private JavaModuleDescriptor jModule;
83          
84          private Builder( String name )
85          {
86              jModule = new JavaModuleDescriptor();
87              jModule.name = name;
88          }
89          
90          private Builder setAutomatic( boolean isAutomatic )
91          {
92              jModule.automatic = isAutomatic;
93              return this;
94          }
95  
96          public Builder requires( String name )
97          {
98              JavaRequires requires = new JavaRequires( name );
99              jModule.requires.add( requires );
100             return this;
101         }
102         
103         public Builder exports( String source )
104         {
105             JavaExports exports = new JavaExports( source );
106             jModule.exports.add( exports );
107             return this;
108         }
109         
110         public JavaModuleDescriptor build()
111         {
112             return jModule;
113         }
114     }
115     
116     
117 
118 
119 
120 
121 
122     public static class JavaRequires
123     {
124         private final String name;
125 
126         private JavaRequires( String name )
127         {
128             this.name = name;
129         }
130 
131         public String name()
132         {
133             return name;
134         }
135     }
136     
137     
138 
139 
140 
141 
142 
143 
144     public static class JavaExports
145     {
146         private final String source;
147         
148         private JavaExports( String source )
149         {
150             this.source = source;
151         }
152         
153         public String source()
154         {
155             return source;
156         }
157     }
158     
159 }