001    package org.apache.archiva.maven2.model;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import javax.xml.bind.annotation.XmlRootElement;
023    import java.io.Serializable;
024    import java.util.List;
025    
026    @XmlRootElement( name = "artifact" )
027    public class Artifact
028        implements Serializable
029    {
030        // The (optional) context for this result.
031        private String context;
032    
033        // Basic hit, direct to non-artifact resource.
034        private String url;
035    
036        // Advanced hit, reference to groupId.
037        private String groupId;
038    
039        //  Advanced hit, reference to artifactId.
040        private String artifactId;
041    
042        private String repositoryId;
043    
044        private String version;
045    
046        /**
047         * Plugin goal prefix (only if packaging is "maven-plugin")
048         */
049        private String prefix;
050    
051        /**
052         * Plugin goals (only if packaging is "maven-plugin")
053         */
054        private List<String> goals;
055    
056        /**
057         * contains osgi metadata Bundle-Version if available
058         *
059         * @since 1.4-M1
060         */
061        private String bundleVersion;
062    
063        /**
064         * contains osgi metadata Bundle-SymbolicName if available
065         *
066         * @since 1.4-M1
067         */
068        private String bundleSymbolicName;
069    
070        /**
071         * contains osgi metadata Export-Package if available
072         *
073         * @since 1.4-M1
074         */
075        private String bundleExportPackage;
076    
077        /**
078         * contains osgi metadata Export-Service if available
079         *
080         * @since 1.4-M1
081         */
082        private String bundleExportService;
083    
084        /**
085         * contains osgi metadata Bundle-Description if available
086         *
087         * @since 1.4-M1
088         */
089        private String bundleDescription;
090    
091        /**
092         * contains osgi metadata Bundle-Name if available
093         *
094         * @since 1.4-M1
095         */
096        private String bundleName;
097    
098        /**
099         * contains osgi metadata Bundle-License if available
100         *
101         * @since 1.4-M1
102         */
103        private String bundleLicense;
104    
105        /**
106         * contains osgi metadata Bundle-DocURL if available
107         *
108         * @since 1.4-M1
109         */
110        private String bundleDocUrl;
111    
112        /**
113         * contains osgi metadata Import-Package if available
114         *
115         * @since 1.4-M1
116         */
117        private String bundleImportPackage;
118    
119        /**
120         * contains osgi metadata Require-Bundle if available
121         *
122         * @since 1.4-M1
123         */
124        private String bundleRequireBundle;
125    
126        private String classifier;
127    
128        private String packaging;
129    
130        /**
131         * file extension of the artifact
132         *
133         * @since 1.4-M2
134         */
135        private String fileExtension;
136    
137        /**
138         * human readable size : not available for all services
139         *
140         * @since 1.4-M3
141         */
142        private String size;
143    
144        /**
145         * @since 1.4-M3
146         */
147        private String type;
148    
149    
150        /**
151         * @since 1.4-M3
152         */
153        private String path;
154    
155        /**
156         * concat of artifactId+'-'+version+'.'+type
157         *
158         * @since 1.4-M3
159         */
160        private String id;
161    
162        /**
163         * @since 1.4-M3
164         */
165        private String scope;
166    
167    
168        public Artifact()
169        {
170            // no op
171        }
172    
173        public Artifact( String groupId, String artifactId, String version )
174        {
175            this.artifactId = artifactId;
176            this.groupId = groupId;
177            this.version = version;
178        }
179    
180        /**
181         * @since 1.4-M3
182         */
183        public Artifact( String groupId, String artifactId, String version, String scope )
184        {
185            this( groupId, artifactId, version );
186            this.scope = scope;
187        }
188    
189        /**
190         * @since 1.4-M3
191         */
192        public Artifact( String groupId, String artifactId, String version, String scope, String classifier )
193        {
194            this( groupId, artifactId, version );
195            this.scope = scope;
196            this.classifier = classifier;
197        }
198    
199        public String getGroupId()
200        {
201            return groupId;
202        }
203    
204        public String getArtifactId()
205        {
206            return artifactId;
207        }
208    
209        public String getVersion()
210        {
211            return version;
212        }
213    
214        public String getRepositoryId()
215        {
216            return repositoryId;
217        }
218    
219        public void setGroupId( String groupId )
220        {
221            this.groupId = groupId;
222        }
223    
224        public void setArtifactId( String artifactId )
225        {
226            this.artifactId = artifactId;
227        }
228    
229        public void setVersion( String version )
230        {
231            this.version = version;
232        }
233    
234        public void setRepositoryId( String repositoryId )
235        {
236            this.repositoryId = repositoryId;
237        }
238    
239        public String getContext()
240        {
241            return context;
242        }
243    
244        public void setContext( String context )
245        {
246            this.context = context;
247        }
248    
249        public String getUrl()
250        {
251            return url;
252        }
253    
254        public void setUrl( String url )
255        {
256            this.url = url;
257        }
258    
259        public String getPrefix()
260        {
261            return prefix;
262        }
263    
264        public void setPrefix( String prefix )
265        {
266            this.prefix = prefix;
267        }
268    
269        public List<String> getGoals()
270        {
271            return goals;
272        }
273    
274        public void setGoals( List<String> goals )
275        {
276            this.goals = goals;
277        }
278    
279        public String getBundleVersion()
280        {
281            return bundleVersion;
282        }
283    
284        public void setBundleVersion( String bundleVersion )
285        {
286            this.bundleVersion = bundleVersion;
287        }
288    
289        public String getBundleSymbolicName()
290        {
291            return bundleSymbolicName;
292        }
293    
294        public void setBundleSymbolicName( String bundleSymbolicName )
295        {
296            this.bundleSymbolicName = bundleSymbolicName;
297        }
298    
299        public String getBundleExportPackage()
300        {
301            return bundleExportPackage;
302        }
303    
304        public void setBundleExportPackage( String bundleExportPackage )
305        {
306            this.bundleExportPackage = bundleExportPackage;
307        }
308    
309        public String getBundleExportService()
310        {
311            return bundleExportService;
312        }
313    
314        public void setBundleExportService( String bundleExportService )
315        {
316            this.bundleExportService = bundleExportService;
317        }
318    
319        public String getBundleDescription()
320        {
321            return bundleDescription;
322        }
323    
324        public void setBundleDescription( String bundleDescription )
325        {
326            this.bundleDescription = bundleDescription;
327        }
328    
329        public String getBundleName()
330        {
331            return bundleName;
332        }
333    
334        public void setBundleName( String bundleName )
335        {
336            this.bundleName = bundleName;
337        }
338    
339        public String getBundleLicense()
340        {
341            return bundleLicense;
342        }
343    
344        public void setBundleLicense( String bundleLicense )
345        {
346            this.bundleLicense = bundleLicense;
347        }
348    
349        public String getBundleDocUrl()
350        {
351            return bundleDocUrl;
352        }
353    
354        public void setBundleDocUrl( String bundleDocUrl )
355        {
356            this.bundleDocUrl = bundleDocUrl;
357        }
358    
359        public String getBundleImportPackage()
360        {
361            return bundleImportPackage;
362        }
363    
364        public void setBundleImportPackage( String bundleImportPackage )
365        {
366            this.bundleImportPackage = bundleImportPackage;
367        }
368    
369        public String getBundleRequireBundle()
370        {
371            return bundleRequireBundle;
372        }
373    
374        public void setBundleRequireBundle( String bundleRequireBundle )
375        {
376            this.bundleRequireBundle = bundleRequireBundle;
377        }
378    
379        public String getClassifier()
380        {
381            return classifier;
382        }
383    
384        public void setClassifier( String classifier )
385        {
386            this.classifier = classifier;
387        }
388    
389    
390        public String getPackaging()
391        {
392            return packaging;
393        }
394    
395        public void setPackaging( String packaging )
396        {
397            this.packaging = packaging;
398        }
399    
400        public String getFileExtension()
401        {
402            return fileExtension;
403        }
404    
405        public void setFileExtension( String fileExtension )
406        {
407            this.fileExtension = fileExtension;
408        }
409    
410        public String getSize()
411        {
412            return size;
413        }
414    
415        public void setSize( String size )
416        {
417            this.size = size;
418        }
419    
420        public String getType()
421        {
422            return type;
423        }
424    
425        public void setType( String type )
426        {
427            this.type = type;
428        }
429    
430        public String getPath()
431        {
432            return path;
433        }
434    
435        public void setPath( String path )
436        {
437            this.path = path;
438        }
439    
440        public String getId()
441        {
442            return id;
443        }
444    
445        public void setId( String id )
446        {
447            this.id = id;
448        }
449    
450        public String getScope()
451        {
452            return scope;
453        }
454    
455        public void setScope( String scope )
456        {
457            this.scope = scope;
458        }
459    
460        @Override
461        public String toString()
462        {
463            final StringBuilder sb = new StringBuilder();
464            sb.append( "Artifact" );
465            sb.append( "{context='" ).append( context ).append( '\'' );
466            sb.append( ", url='" ).append( url ).append( '\'' );
467            sb.append( ", groupId='" ).append( groupId ).append( '\'' );
468            sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
469            sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
470            sb.append( ", version='" ).append( version ).append( '\'' );
471            sb.append( ", prefix='" ).append( prefix ).append( '\'' );
472            sb.append( ", goals=" ).append( goals );
473            sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
474            sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
475            sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
476            sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
477            sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
478            sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
479            sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
480            sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
481            sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
482            sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
483            sb.append( ", classifier='" ).append( classifier ).append( '\'' );
484            sb.append( ", packaging='" ).append( packaging ).append( '\'' );
485            sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
486            sb.append( ", size='" ).append( size ).append( '\'' );
487            sb.append( ", type='" ).append( type ).append( '\'' );
488            sb.append( ", path='" ).append( path ).append( '\'' );
489            sb.append( ", id='" ).append( id ).append( '\'' );
490            sb.append( '}' );
491            return sb.toString();
492        }
493    
494        @Override
495        public boolean equals( Object o )
496        {
497            if ( this == o )
498            {
499                return true;
500            }
501            if ( !( o instanceof Artifact ) )
502            {
503                return false;
504            }
505    
506            Artifact artifact = (Artifact) o;
507    
508            if ( !artifactId.equals( artifact.artifactId ) )
509            {
510                return false;
511            }
512            if ( bundleDescription != null
513                ? !bundleDescription.equals( artifact.bundleDescription )
514                : artifact.bundleDescription != null )
515            {
516                return false;
517            }
518            if ( bundleDocUrl != null ? !bundleDocUrl.equals( artifact.bundleDocUrl ) : artifact.bundleDocUrl != null )
519            {
520                return false;
521            }
522            if ( bundleExportPackage != null
523                ? !bundleExportPackage.equals( artifact.bundleExportPackage )
524                : artifact.bundleExportPackage != null )
525            {
526                return false;
527            }
528            if ( bundleExportService != null
529                ? !bundleExportService.equals( artifact.bundleExportService )
530                : artifact.bundleExportService != null )
531            {
532                return false;
533            }
534            if ( bundleImportPackage != null
535                ? !bundleImportPackage.equals( artifact.bundleImportPackage )
536                : artifact.bundleImportPackage != null )
537            {
538                return false;
539            }
540            if ( bundleLicense != null ? !bundleLicense.equals( artifact.bundleLicense ) : artifact.bundleLicense != null )
541            {
542                return false;
543            }
544            if ( bundleName != null ? !bundleName.equals( artifact.bundleName ) : artifact.bundleName != null )
545            {
546                return false;
547            }
548            if ( bundleRequireBundle != null
549                ? !bundleRequireBundle.equals( artifact.bundleRequireBundle )
550                : artifact.bundleRequireBundle != null )
551            {
552                return false;
553            }
554            if ( bundleSymbolicName != null
555                ? !bundleSymbolicName.equals( artifact.bundleSymbolicName )
556                : artifact.bundleSymbolicName != null )
557            {
558                return false;
559            }
560            if ( bundleVersion != null ? !bundleVersion.equals( artifact.bundleVersion ) : artifact.bundleVersion != null )
561            {
562                return false;
563            }
564            if ( classifier != null ? !classifier.equals( artifact.classifier ) : artifact.classifier != null )
565            {
566                return false;
567            }
568            if ( context != null ? !context.equals( artifact.context ) : artifact.context != null )
569            {
570                return false;
571            }
572            if ( fileExtension != null ? !fileExtension.equals( artifact.fileExtension ) : artifact.fileExtension != null )
573            {
574                return false;
575            }
576            if ( goals != null ? !goals.equals( artifact.goals ) : artifact.goals != null )
577            {
578                return false;
579            }
580            if ( !groupId.equals( artifact.groupId ) )
581            {
582                return false;
583            }
584            if ( id != null ? !id.equals( artifact.id ) : artifact.id != null )
585            {
586                return false;
587            }
588            if ( packaging != null ? !packaging.equals( artifact.packaging ) : artifact.packaging != null )
589            {
590                return false;
591            }
592            if ( path != null ? !path.equals( artifact.path ) : artifact.path != null )
593            {
594                return false;
595            }
596            if ( prefix != null ? !prefix.equals( artifact.prefix ) : artifact.prefix != null )
597            {
598                return false;
599            }
600            if ( repositoryId != null ? !repositoryId.equals( artifact.repositoryId ) : artifact.repositoryId != null )
601            {
602                return false;
603            }
604            if ( scope != null ? !scope.equals( artifact.scope ) : artifact.scope != null )
605            {
606                return false;
607            }
608            if ( size != null ? !size.equals( artifact.size ) : artifact.size != null )
609            {
610                return false;
611            }
612            if ( type != null ? !type.equals( artifact.type ) : artifact.type != null )
613            {
614                return false;
615            }
616            if ( url != null ? !url.equals( artifact.url ) : artifact.url != null )
617            {
618                return false;
619            }
620            if ( !version.equals( artifact.version ) )
621            {
622                return false;
623            }
624    
625            return true;
626        }
627    
628        @Override
629        public int hashCode()
630        {
631            int result = context != null ? context.hashCode() : 0;
632            result = 31 * result + ( url != null ? url.hashCode() : 0 );
633            result = 31 * result + groupId.hashCode();
634            result = 31 * result + artifactId.hashCode();
635            result = 31 * result + ( repositoryId != null ? repositoryId.hashCode() : 0 );
636            result = 31 * result + version.hashCode();
637            result = 31 * result + ( prefix != null ? prefix.hashCode() : 0 );
638            result = 31 * result + ( goals != null ? goals.hashCode() : 0 );
639            result = 31 * result + ( bundleVersion != null ? bundleVersion.hashCode() : 0 );
640            result = 31 * result + ( bundleSymbolicName != null ? bundleSymbolicName.hashCode() : 0 );
641            result = 31 * result + ( bundleExportPackage != null ? bundleExportPackage.hashCode() : 0 );
642            result = 31 * result + ( bundleExportService != null ? bundleExportService.hashCode() : 0 );
643            result = 31 * result + ( bundleDescription != null ? bundleDescription.hashCode() : 0 );
644            result = 31 * result + ( bundleName != null ? bundleName.hashCode() : 0 );
645            result = 31 * result + ( bundleLicense != null ? bundleLicense.hashCode() : 0 );
646            result = 31 * result + ( bundleDocUrl != null ? bundleDocUrl.hashCode() : 0 );
647            result = 31 * result + ( bundleImportPackage != null ? bundleImportPackage.hashCode() : 0 );
648            result = 31 * result + ( bundleRequireBundle != null ? bundleRequireBundle.hashCode() : 0 );
649            result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
650            result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
651            result = 31 * result + ( fileExtension != null ? fileExtension.hashCode() : 0 );
652            result = 31 * result + ( size != null ? size.hashCode() : 0 );
653            result = 31 * result + ( type != null ? type.hashCode() : 0 );
654            result = 31 * result + ( path != null ? path.hashCode() : 0 );
655            result = 31 * result + ( id != null ? id.hashCode() : 0 );
656            result = 31 * result + ( scope != null ? scope.hashCode() : 0 );
657            return result;
658        }
659    }