View Javadoc
1   package org.apache.maven.archetype.old.descriptor;
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.HashMap;
24  import java.util.List;
25  import java.util.Map;
26  
27  public class ArchetypeDescriptor
28  {
29      private String id;
30  
31      private List<String> sources;
32  
33      private List<String> testSources;
34  
35      private List<String> resources;
36  
37      private List<String> testResources;
38  
39      private List<String> siteResources;
40  
41      /**
42       * <code>Map</code> that associates the items in the <code>List</code>
43       * <code>sources</code> with their attributes (instances of
44       * <code>TemplateDescriptor</code>.
45       */
46      private Map<String, TemplateDescriptor> sourcesDescriptors;
47  
48      /**
49       * <code>Map</code> that associates the items in the <code>List</code>
50       * <code>testSources</code> with their attributes (instances of
51       * <code>TemplateDescriptor</code>.
52       */
53      private Map<String, TemplateDescriptor> testSourcesDescriptors;
54  
55      /**
56       * <code>Map</code> that associates the items in the <code>List</code>
57       * <code>resources</code> with their attributes (instances of
58       * <code>TemplateDescriptor</code>.
59       */
60      private Map<String, TemplateDescriptor> resourcesDescriptors;
61  
62      /**
63       * <code>Map</code> that associates the items in the <code>List</code>
64       * <code>testResources</code> with their attributes (instances of
65       * <code>TemplateDescriptor</code>.
66       */
67      private Map<String, TemplateDescriptor> testResourcesDescriptors;
68  
69      /**
70       * <code>Map</code> that associates the items in the <code>List</code>
71       * <code>siteResources</code> with their attributes (instances of
72       * <code>TemplateDescriptor</code>.
73       */
74      private Map<String, TemplateDescriptor> siteResourcesDescriptors;
75  
76      /**
77       * This indicates the archetype can be a whole project or can be part
78       * of another project. An example is a site archetype where the POM and
79       * directory structure may already exist and you simply want to generate
80       * the site directory structure.
81       */
82      private boolean allowPartial;
83  
84      public ArchetypeDescriptor()
85      {
86          sources = new ArrayList<>();
87  
88          resources = new ArrayList<>();
89  
90          testSources = new ArrayList<>();
91  
92          testResources = new ArrayList<>();
93  
94          siteResources = new ArrayList<>();
95  
96          sourcesDescriptors = new HashMap<>();
97  
98          testSourcesDescriptors = new HashMap<>();
99  
100         resourcesDescriptors = new HashMap<>();
101 
102         testResourcesDescriptors = new HashMap<>();
103 
104         siteResourcesDescriptors = new HashMap<>();
105     }
106 
107     // ----------------------------------------------------------------------
108     //
109     // ----------------------------------------------------------------------
110 
111     public String getId()
112     {
113         return id;
114     }
115 
116     public void setId( String id )
117     {
118         this.id = id;
119     }
120 
121     public void addSource( String source )
122     {
123         sources.add( source );
124 
125         putSourceDescriptor( source, new TemplateDescriptor() );
126     }
127 
128     public List<String> getSources()
129     {
130         return sources;
131     }
132 
133     public void putSourceDescriptor( String source, TemplateDescriptor descriptor )
134     {
135         sourcesDescriptors.put( source, descriptor );
136     }
137 
138     public TemplateDescriptor getSourceDescriptor( String source )
139     {
140         return sourcesDescriptors.get( source );
141     }
142 
143     public Map<String, TemplateDescriptor> getSourcesDescriptors()
144     {
145         return sourcesDescriptors;
146     }
147 
148     public void addTestSource( String testSource )
149     {
150         testSources.add( testSource );
151 
152         putTestSourceDescriptor( testSource, new TemplateDescriptor() );
153     }
154 
155     public List<String> getTestSources()
156     {
157         return testSources;
158     }
159 
160     public void putTestSourceDescriptor( String testSource, TemplateDescriptor descriptor )
161     {
162         testSourcesDescriptors.put( testSource, descriptor );
163     }
164 
165     public TemplateDescriptor getTestSourceDescriptor( String testSource )
166     {
167         return testSourcesDescriptors.get( testSource );
168     }
169 
170     public Map<String, TemplateDescriptor> getTestSourcesDescriptors()
171     {
172         return testSourcesDescriptors;
173     }
174 
175     public void addResource( String resource )
176     {
177         resources.add( resource );
178 
179         putResourceDescriptor( resource, new TemplateDescriptor() );
180     }
181 
182     public List<String> getResources()
183     {
184         return resources;
185     }
186 
187     public void putResourceDescriptor( String resource, TemplateDescriptor descriptor )
188     {
189         resourcesDescriptors.put( resource, descriptor );
190     }
191 
192     public TemplateDescriptor getResourceDescriptor( String resource )
193     {
194         return resourcesDescriptors.get( resource );
195     }
196 
197     public Map<String, TemplateDescriptor> getReourcesDescriptors()
198     {
199         return resourcesDescriptors;
200     }
201 
202     public void addTestResource( String testResource )
203     {
204         testResources.add( testResource );
205         putTestResourceDescriptor( testResource, new TemplateDescriptor() );
206     }
207 
208     public List<String> getTestResources()
209     {
210         return testResources;
211     }
212 
213     public void putTestResourceDescriptor( String testResource, TemplateDescriptor descriptor )
214     {
215         testResourcesDescriptors.put( testResource, descriptor );
216     }
217 
218     public TemplateDescriptor getTestResourceDescriptor( String testResource )
219     {
220         return testResourcesDescriptors.get( testResource );
221     }
222 
223     public Map<String, TemplateDescriptor> getTestReourcesDescriptors()
224     {
225         return testResourcesDescriptors;
226     }
227 
228     public void addSiteResource( String siteResource )
229     {
230         siteResources.add( siteResource );
231 
232         putSiteResourceDescriptor( siteResource, new TemplateDescriptor() );
233     }
234 
235     public List<String> getSiteResources()
236     {
237         return siteResources;
238     }
239 
240     public void putSiteResourceDescriptor( String siteResource, TemplateDescriptor descriptor )
241     {
242         siteResourcesDescriptors.put( siteResource, descriptor );
243     }
244 
245     public TemplateDescriptor getSiteResourceDescriptor( String siteResource )
246     {
247         return siteResourcesDescriptors.get( siteResource );
248     }
249 
250     public Map<String, TemplateDescriptor> getSiteReourcesDescriptors()
251     {
252         return siteResourcesDescriptors;
253     }
254 
255     public boolean isAllowPartial()
256     {
257         return allowPartial;
258     }
259 
260     public void setAllowPartial( boolean allowPartial )
261     {
262         this.allowPartial = allowPartial;
263     }
264 }