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