View Javadoc

1   package org.apache.maven.plugin.ear;
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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.handler.ArtifactHandler;
24  import org.apache.maven.artifact.metadata.ArtifactMetadata;
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
27  import org.apache.maven.artifact.versioning.ArtifactVersion;
28  import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
29  import org.apache.maven.artifact.versioning.VersionRange;
30  
31  import java.io.File;
32  import java.util.Collection;
33  import java.util.List;
34  
35  /**
36   * A fake {@link Artifact} test stub.
37   *
38   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
39   * @version $Id: ArtifactTestStub.java 992748 2010-09-05 09:49:46Z snicoll $
40   */
41  public class ArtifactTestStub
42      implements Artifact
43  
44  {
45      public static final String DEFAULT_VERSION = "1.0";
46  
47      private final String groupId;
48  
49      private final String artifactId;
50  
51      private final String type;
52  
53      private final String classifier;
54  
55      private String version;
56  
57  
58      public ArtifactTestStub( String groupId, String artifactId, String type, String classifier, String version )
59      {
60          this.groupId = groupId;
61          this.artifactId = artifactId;
62          this.type = type;
63          this.classifier = classifier;
64          this.version = version;
65      }
66  
67      public ArtifactTestStub( String groupId, String artifactId, String type, String classifier )
68      {
69          this( groupId, artifactId, type, classifier, DEFAULT_VERSION );
70      }
71  
72  
73      public String getGroupId()
74      {
75          return groupId;
76      }
77  
78      public String getArtifactId()
79      {
80          return artifactId;
81      }
82  
83      public String getVersion()
84      {
85          return version;
86      }
87  
88      public void setVersion( String version )
89      {
90          this.version = version;
91      }
92  
93      public String getScope()
94      {
95          throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
96      }
97  
98      public String getType()
99      {
100         return type;
101     }
102 
103     public String getClassifier()
104     {
105         return classifier;
106     }
107 
108     public boolean hasClassifier()
109     {
110         return classifier != null;
111     }
112 
113     public File getFile()
114     {
115         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
116     }
117 
118     public void setFile( File file )
119     {
120         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
121     }
122 
123     public String getBaseVersion()
124     {
125         return version;
126     }
127 
128     public void setBaseVersion( String string )
129     {
130         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
131     }
132 
133     public String getId()
134     {
135         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
136     }
137 
138     public String getDependencyConflictId()
139     {
140         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
141     }
142 
143     public void addMetadata( ArtifactMetadata artifactMetadata )
144     {
145         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
146     }
147 
148     public Collection getMetadataList()
149     {
150         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
151     }
152 
153     public void setRepository( ArtifactRepository artifactRepository )
154     {
155         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
156     }
157 
158     public ArtifactRepository getRepository()
159     {
160         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
161     }
162 
163     public void updateVersion( String string, ArtifactRepository artifactRepository )
164     {
165         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
166     }
167 
168     public String getDownloadUrl()
169     {
170         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
171     }
172 
173     public void setDownloadUrl( String string )
174     {
175         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
176     }
177 
178     public ArtifactFilter getDependencyFilter()
179     {
180         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
181     }
182 
183     public void setDependencyFilter( ArtifactFilter artifactFilter )
184     {
185         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
186     }
187 
188     public ArtifactHandler getArtifactHandler()
189     {
190         return new ArtifactHandlerTestStub( "jar" );
191     }
192 
193     public List getDependencyTrail()
194     {
195         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
196     }
197 
198     public void setDependencyTrail( List list )
199     {
200         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
201     }
202 
203     public void setScope( String string )
204     {
205         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
206     }
207 
208     public VersionRange getVersionRange()
209     {
210         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
211     }
212 
213     public void setVersionRange( VersionRange versionRange )
214     {
215         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
216     }
217 
218     public void selectVersion( String string )
219     {
220         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
221     }
222 
223     public void setGroupId( String string )
224     {
225         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
226     }
227 
228     public void setArtifactId( String string )
229     {
230         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
231     }
232 
233     public boolean isSnapshot()
234     {
235         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
236     }
237 
238     public void setResolved( boolean b )
239     {
240         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
241     }
242 
243     public boolean isResolved()
244     {
245         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
246     }
247 
248     public void setResolvedVersion( String string )
249     {
250         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
251     }
252 
253     public void setArtifactHandler( ArtifactHandler artifactHandler )
254     {
255         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
256     }
257 
258     public boolean isRelease()
259     {
260         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
261     }
262 
263     public void setRelease( boolean b )
264     {
265         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
266     }
267 
268     public List getAvailableVersions()
269     {
270         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
271     }
272 
273     public void setAvailableVersions( List list )
274     {
275         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
276     }
277 
278     public boolean isOptional()
279     {
280         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
281     }
282 
283     public void setOptional( boolean b )
284     {
285         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
286     }
287 
288     public ArtifactVersion getSelectedVersion()
289         throws OverConstrainedVersionException
290     {
291         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
292     }
293 
294     public boolean isSelectedVersionKnown()
295         throws OverConstrainedVersionException
296     {
297         throw new UnsupportedOperationException( "not implemented ; fake artifact stub" );
298     }
299 
300     public int compareTo( Object o )
301     {
302         if ( this.equals( o ) )
303         {
304             return 0;
305         }
306         else
307         {
308             return 1;
309         }
310     }
311 
312     public boolean equals( Object o )
313     {
314         if ( this == o )
315         {
316             return true;
317         }
318         if ( o == null || getClass() != o.getClass() )
319         {
320             return false;
321         }
322 
323         ArtifactTestStub that = (ArtifactTestStub) o;
324 
325         if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null )
326         {
327             return false;
328         }
329         if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null )
330         {
331             return false;
332         }
333         if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null )
334         {
335             return false;
336         }
337         if ( type != null ? !type.equals( that.type ) : that.type != null )
338         {
339             return false;
340         }
341 
342         return true;
343     }
344 
345     public int hashCode()
346     {
347         int result;
348         result = ( groupId != null ? groupId.hashCode() : 0 );
349         result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 );
350         result = 31 * result + ( type != null ? type.hashCode() : 0 );
351         result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
352         return result;
353     }
354 }
355