KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > artifact > ArtifactStatus


1 package org.apache.maven.artifact;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22 /**
23  * Type safe enumeration for the artifact status field.
24  *
25  * @author <a HREF="mailto:brett@apache.org">Brett Porter</a>
26  * @version $Id: ArtifactStatus.java 225718 2005-07-28 07:14:33Z brett $
27  */

28 public final class ArtifactStatus
29     implements Comparable JavaDoc
30 {
31     /**
32      * No trust - no information about status.
33      */

34     public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 );
35
36     /**
37      * No trust - information was generated with defaults.
38      */

39     public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 );
40
41     /**
42      * Low trust - was converted from the Maven 1.x repository.
43      */

44     public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 );
45
46     /**
47      * Moderate trust - it was deployed directly from a partner.
48      */

49     public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 );
50
51     /**
52      * Moderate trust - it was deployed directly by a user.
53      */

54     public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 );
55
56     /**
57      * Trusted, as it has had its data verified by hand.
58      */

59     public static final ArtifactStatus VERIFIED = new ArtifactStatus( "verified", 5 );
60
61     private final int rank;
62
63     private final String JavaDoc key;
64
65     private static Map JavaDoc map;
66
67     private ArtifactStatus( String JavaDoc key, int rank )
68     {
69         this.rank = rank;
70         this.key = key;
71
72         if ( map == null )
73         {
74             map = new HashMap JavaDoc();
75         }
76         map.put( key, this );
77     }
78
79     public static ArtifactStatus valueOf( String JavaDoc status )
80     {
81         ArtifactStatus retVal = null;
82
83         if ( status != null )
84         {
85             retVal = (ArtifactStatus) map.get( status );
86         }
87
88         return retVal != null ? retVal : NONE;
89     }
90
91     public boolean equals( Object JavaDoc o )
92     {
93         if ( this == o )
94         {
95             return true;
96         }
97         if ( o == null || getClass() != o.getClass() )
98         {
99             return false;
100         }
101
102         final ArtifactStatus that = (ArtifactStatus) o;
103
104         return rank == that.rank;
105
106     }
107
108     public int hashCode()
109     {
110         return rank;
111     }
112
113     public String JavaDoc toString()
114     {
115         return key;
116     }
117
118     public int compareTo( Object JavaDoc o )
119     {
120         ArtifactStatus s = (ArtifactStatus) o;
121         return rank - s.rank;
122     }
123 }
124
Popular Tags