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   * Describes a build extension to utilise.
28   * 
29   * @version $Revision$ $Date$
30   */
31  @SuppressWarnings( "all" )
32  public class Extension
33      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
34  {
35  
36        //--------------------------/
37       //- Class/Member Variables -/
38      //--------------------------/
39  
40      /**
41       * The group ID of the extension's artifact.
42       */
43      private String groupId;
44  
45      /**
46       * The artifact ID of the extension.
47       */
48      private String artifactId;
49  
50      /**
51       * The version of the extension.
52       */
53      private String version;
54  
55      /**
56       * Field locations.
57       */
58      private java.util.Map<Object, InputLocation> locations;
59  
60      /**
61       * Field location.
62       */
63      private InputLocation location;
64  
65      /**
66       * Field groupIdLocation.
67       */
68      private InputLocation groupIdLocation;
69  
70      /**
71       * Field artifactIdLocation.
72       */
73      private InputLocation artifactIdLocation;
74  
75      /**
76       * Field versionLocation.
77       */
78      private InputLocation versionLocation;
79  
80  
81        //-----------/
82       //- Methods -/
83      //-----------/
84  
85      /**
86       * Method clone.
87       * 
88       * @return Extension
89       */
90      public Extension clone()
91      {
92          try
93          {
94              Extension copy = (Extension) super.clone();
95  
96              if ( copy.locations != null )
97              {
98                  copy.locations = new java.util.LinkedHashMap( copy.locations );
99              }
100 
101             return copy;
102         }
103         catch ( java.lang.Exception ex )
104         {
105             throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
106                 + " does not support clone()" ).initCause( ex );
107         }
108     } //-- Extension clone()
109 
110     /**
111      * Get the artifact ID of the extension.
112      * 
113      * @return String
114      */
115     public String getArtifactId()
116     {
117         return this.artifactId;
118     } //-- String getArtifactId()
119 
120     /**
121      * Get the group ID of the extension's artifact.
122      * 
123      * @return String
124      */
125     public String getGroupId()
126     {
127         return this.groupId;
128     } //-- String getGroupId()
129 
130     /**
131      * 
132      * 
133      * @param key a key object.
134      * @return InputLocation
135      */
136     public InputLocation getLocation( Object key )
137     {
138         if ( key instanceof String )
139         {
140             switch ( ( String ) key )
141             {
142                 case "" :
143                 {
144                     return this.location;
145                 }
146                 case "groupId" :
147                 {
148                     return groupIdLocation;
149                 }
150                 case "artifactId" :
151                 {
152                     return artifactIdLocation;
153                 }
154                 case "version" :
155                 {
156                     return versionLocation;
157                 }
158                 default :
159                 {
160                     return getOtherLocation( key );
161                 }
162                 }
163             }
164             else
165             {
166                 return getOtherLocation( key );
167             }
168     } //-- InputLocation getLocation( Object )
169 
170     /**
171      * 
172      * 
173      * @param key a key object.
174      * @param location a location object.
175      */
176     public void setLocation( Object key, InputLocation location )
177     {
178         if ( key instanceof String )
179         {
180             switch ( ( String ) key )
181             {
182                 case "" :
183                 {
184                     this.location = location;
185                     return;
186                 }
187                 case "groupId" :
188                 {
189                     groupIdLocation = location;
190                     return;
191                 }
192                 case "artifactId" :
193                 {
194                     artifactIdLocation = location;
195                     return;
196                 }
197                 case "version" :
198                 {
199                     versionLocation = location;
200                     return;
201                 }
202                 default :
203                 {
204                     setOtherLocation( key, location );
205                     return;
206                 }
207             }
208         }
209         else
210         {
211             setOtherLocation( key, location );
212         }
213     } //-- void setLocation( Object, InputLocation )
214 
215     /**
216      * 
217      * 
218      * @param key a key object.
219      * @param location a location object.
220      */
221     public void setOtherLocation( Object key, InputLocation location )
222     {
223         if ( location != null )
224         {
225             if ( this.locations == null )
226             {
227                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
228             }
229             this.locations.put( key, location );
230         }
231     } //-- void setOtherLocation( Object, InputLocation )
232 
233     /**
234      * 
235      * 
236      * @param key a key object.
237      * @return InputLocation
238      */
239     private InputLocation getOtherLocation( Object key )
240     {
241         return ( locations != null ) ? locations.get( key ) : null;
242     } //-- InputLocation getOtherLocation( Object )
243 
244     /**
245      * Get the version of the extension.
246      * 
247      * @return String
248      */
249     public String getVersion()
250     {
251         return this.version;
252     } //-- String getVersion()
253 
254     /**
255      * Set the artifact ID of the extension.
256      * 
257      * @param artifactId a artifactId object.
258      */
259     public void setArtifactId( String artifactId )
260     {
261         this.artifactId = artifactId;
262     } //-- void setArtifactId( String )
263 
264     /**
265      * Set the group ID of the extension's artifact.
266      * 
267      * @param groupId a groupId object.
268      */
269     public void setGroupId( String groupId )
270     {
271         this.groupId = groupId;
272     } //-- void setGroupId( String )
273 
274     /**
275      * Set the version of the extension.
276      * 
277      * @param version a version object.
278      */
279     public void setVersion( String version )
280     {
281         this.version = version;
282     } //-- void setVersion( String )
283 
284     
285             
286     /**
287      * @see java.lang.Object#equals(java.lang.Object)
288      */
289     public boolean equals( Object o )
290     {
291         if ( this == o )
292         {
293             return true;
294         }
295 
296         if ( !( o instanceof Extension ) )
297         {
298             return false;
299         }
300 
301         Extension e = (Extension) o;
302 
303         if ( !equal( e.getArtifactId(), getArtifactId() ) )
304         {
305             return false;
306         }
307         else if ( !equal( e.getGroupId(), getGroupId() ) )
308         {
309             return false;
310         }
311         else if ( !equal( e.getVersion(), getVersion() ) )
312         {
313             return false;
314         }
315         return true;
316     }
317 
318     private static <T> boolean equal( T obj1, T obj2 )
319     {
320         return ( obj1 != null ) ? obj1.equals( obj2 ) : obj2 == null;
321     }
322 
323     /**
324      * @see java.lang.Object#hashCode()
325      */
326     public int hashCode()
327     {
328         int result = 17;
329         result = 37 * result + ( getArtifactId() != null ? getArtifactId().hashCode() : 0 );
330         result = 37 * result + ( getGroupId() != null ? getGroupId().hashCode() : 0 );
331         result = 37 * result + ( getVersion() != null ? getVersion().hashCode() : 0 );
332         return result;
333     }
334             
335           
336 }