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   =================== DO NOT EDIT THIS FILE ====================
19   Generated by Modello 2.4.0,
20   any modifications will be overwritten.
21   ==============================================================
22   */
23  
24  package org.apache.maven.model;
25  
26  /**
27   * 
28   *         
29   *         The <code>&lt;parent&gt;</code> element contains
30   * information required to locate the parent project from which
31   *         this project will inherit from.
32   *         <strong>Note:</strong> The children of this element are
33   * not interpolated and must be given as literal values.
34   *         
35   *       
36   * 
37   * @version $Revision$ $Date$
38   */
39  @SuppressWarnings( "all" )
40  public class Parent
41      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
42  {
43  
44        //--------------------------/
45       //- Class/Member Variables -/
46      //--------------------------/
47  
48      /**
49       * The group id of the parent project to inherit from.
50       */
51      private String groupId;
52  
53      /**
54       * The artifact id of the parent project to inherit from.
55       */
56      private String artifactId;
57  
58      /**
59       * The version of the parent project to inherit.
60       */
61      private String version;
62  
63      /**
64       * 
65       *             
66       *             The relative path of the parent
67       * <code>pom.xml</code> file within the check out.
68       *             If not specified, it defaults to
69       * <code>../pom.xml</code>.
70       *             Maven looks for the parent POM first in this
71       * location on
72       *             the filesystem, then the local repository, and
73       * lastly in the remote repo.
74       *             <code>relativePath</code> allows you to select a
75       * different location,
76       *             for example when your structure is flat, or
77       * deeper without an intermediate parent POM.
78       *             However, the group ID, artifact ID and version
79       * are still required,
80       *             and must match the file in the location given or
81       * it will revert to the repository for the POM.
82       *             This feature is only for enhancing the
83       * development in a local checkout of that project.
84       *             Set the value to an empty string in case you
85       * want to disable the feature and always resolve
86       *             the parent POM from the repositories.
87       *             
88       *           
89       */
90      private String relativePath = "../pom.xml";
91  
92      /**
93       * Field locations.
94       */
95      private java.util.Map<Object, InputLocation> locations;
96  
97      /**
98       * Field location.
99       */
100     private InputLocation location;
101 
102     /**
103      * Field groupIdLocation.
104      */
105     private InputLocation groupIdLocation;
106 
107     /**
108      * Field artifactIdLocation.
109      */
110     private InputLocation artifactIdLocation;
111 
112     /**
113      * Field versionLocation.
114      */
115     private InputLocation versionLocation;
116 
117     /**
118      * Field relativePathLocation.
119      */
120     private InputLocation relativePathLocation;
121 
122 
123       //-----------/
124      //- Methods -/
125     //-----------/
126 
127     /**
128      * Method clone.
129      * 
130      * @return Parent
131      */
132     public Parent clone()
133     {
134         try
135         {
136             Parent copy = (Parent) super.clone();
137 
138             if ( copy.locations != null )
139             {
140                 copy.locations = new java.util.LinkedHashMap( copy.locations );
141             }
142 
143             return copy;
144         }
145         catch ( java.lang.Exception ex )
146         {
147             throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
148                 + " does not support clone()" ).initCause( ex );
149         }
150     } //-- Parent clone()
151 
152     /**
153      * Get the artifact id of the parent project to inherit from.
154      * 
155      * @return String
156      */
157     public String getArtifactId()
158     {
159         return this.artifactId;
160     } //-- String getArtifactId()
161 
162     /**
163      * Get the group id of the parent project to inherit from.
164      * 
165      * @return String
166      */
167     public String getGroupId()
168     {
169         return this.groupId;
170     } //-- String getGroupId()
171 
172     /**
173      * 
174      * 
175      * @param key a key object.
176      * @return InputLocation
177      */
178     public InputLocation getLocation( Object key )
179     {
180         if ( key instanceof String )
181         {
182             switch ( ( String ) key )
183             {
184                 case "" :
185                 {
186                     return this.location;
187                 }
188                 case "groupId" :
189                 {
190                     return groupIdLocation;
191                 }
192                 case "artifactId" :
193                 {
194                     return artifactIdLocation;
195                 }
196                 case "version" :
197                 {
198                     return versionLocation;
199                 }
200                 case "relativePath" :
201                 {
202                     return relativePathLocation;
203                 }
204                 default :
205                 {
206                     return getOtherLocation( key );
207                 }
208                 }
209             }
210             else
211             {
212                 return getOtherLocation( key );
213             }
214     } //-- InputLocation getLocation( Object )
215 
216     /**
217      * 
218      * 
219      * @param key a key object.
220      * @param location a location object.
221      */
222     public void setLocation( Object key, InputLocation location )
223     {
224         if ( key instanceof String )
225         {
226             switch ( ( String ) key )
227             {
228                 case "" :
229                 {
230                     this.location = location;
231                     return;
232                 }
233                 case "groupId" :
234                 {
235                     groupIdLocation = location;
236                     return;
237                 }
238                 case "artifactId" :
239                 {
240                     artifactIdLocation = location;
241                     return;
242                 }
243                 case "version" :
244                 {
245                     versionLocation = location;
246                     return;
247                 }
248                 case "relativePath" :
249                 {
250                     relativePathLocation = location;
251                     return;
252                 }
253                 default :
254                 {
255                     setOtherLocation( key, location );
256                     return;
257                 }
258             }
259         }
260         else
261         {
262             setOtherLocation( key, location );
263         }
264     } //-- void setLocation( Object, InputLocation )
265 
266     /**
267      * 
268      * 
269      * @param key a key object.
270      * @param location a location object.
271      */
272     public void setOtherLocation( Object key, InputLocation location )
273     {
274         if ( location != null )
275         {
276             if ( this.locations == null )
277             {
278                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
279             }
280             this.locations.put( key, location );
281         }
282     } //-- void setOtherLocation( Object, InputLocation )
283 
284     /**
285      * 
286      * 
287      * @param key a key object.
288      * @return InputLocation
289      */
290     private InputLocation getOtherLocation( Object key )
291     {
292         return ( locations != null ) ? locations.get( key ) : null;
293     } //-- InputLocation getOtherLocation( Object )
294 
295     /**
296      * Get the relative path of the parent <code>pom.xml</code>
297      * file within the check out.
298      *             If not specified, it defaults to
299      * <code>../pom.xml</code>.
300      *             Maven looks for the parent POM first in this
301      * location on
302      *             the filesystem, then the local repository, and
303      * lastly in the remote repo.
304      *             <code>relativePath</code> allows you to select a
305      * different location,
306      *             for example when your structure is flat, or
307      * deeper without an intermediate parent POM.
308      *             However, the group ID, artifact ID and version
309      * are still required,
310      *             and must match the file in the location given or
311      * it will revert to the repository for the POM.
312      *             This feature is only for enhancing the
313      * development in a local checkout of that project.
314      *             Set the value to an empty string in case you
315      * want to disable the feature and always resolve
316      *             the parent POM from the repositories.
317      * 
318      * @return String
319      */
320     public String getRelativePath()
321     {
322         return this.relativePath;
323     } //-- String getRelativePath()
324 
325     /**
326      * Get the version of the parent project to inherit.
327      * 
328      * @return String
329      */
330     public String getVersion()
331     {
332         return this.version;
333     } //-- String getVersion()
334 
335     /**
336      * Set the artifact id of the parent project to inherit from.
337      * 
338      * @param artifactId a artifactId object.
339      */
340     public void setArtifactId( String artifactId )
341     {
342         this.artifactId = artifactId;
343     } //-- void setArtifactId( String )
344 
345     /**
346      * Set the group id of the parent project to inherit from.
347      * 
348      * @param groupId a groupId object.
349      */
350     public void setGroupId( String groupId )
351     {
352         this.groupId = groupId;
353     } //-- void setGroupId( String )
354 
355     /**
356      * Set the relative path of the parent <code>pom.xml</code>
357      * file within the check out.
358      *             If not specified, it defaults to
359      * <code>../pom.xml</code>.
360      *             Maven looks for the parent POM first in this
361      * location on
362      *             the filesystem, then the local repository, and
363      * lastly in the remote repo.
364      *             <code>relativePath</code> allows you to select a
365      * different location,
366      *             for example when your structure is flat, or
367      * deeper without an intermediate parent POM.
368      *             However, the group ID, artifact ID and version
369      * are still required,
370      *             and must match the file in the location given or
371      * it will revert to the repository for the POM.
372      *             This feature is only for enhancing the
373      * development in a local checkout of that project.
374      *             Set the value to an empty string in case you
375      * want to disable the feature and always resolve
376      *             the parent POM from the repositories.
377      * 
378      * @param relativePath a relativePath object.
379      */
380     public void setRelativePath( String relativePath )
381     {
382         this.relativePath = relativePath;
383     } //-- void setRelativePath( String )
384 
385     /**
386      * Set the version of the parent project to inherit.
387      * 
388      * @param version a version object.
389      */
390     public void setVersion( String version )
391     {
392         this.version = version;
393     } //-- void setVersion( String )
394 
395     
396             
397     /**
398      * @return the id as <code>groupId:artifactId:version</code>
399      */
400     public String getId()
401     {
402         StringBuilder id = new StringBuilder( 64 );
403 
404         id.append( getGroupId() );
405         id.append( ":" );
406         id.append( getArtifactId() );
407         id.append( ":" );
408         id.append( "pom" );
409         id.append( ":" );
410         id.append( getVersion() );
411 
412         return id.toString();
413     }
414 
415     @Override
416     public String toString()
417     {
418         return getId();
419     }
420             
421           
422 }