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