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   */
19  package org.apache.maven.artifact;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  /**
25   * Type safe enumeration for the artifact status field.
26   *
27   */
28  @Deprecated
29  public final class ArtifactStatus implements Comparable<ArtifactStatus> {
30      /**
31       * No trust - no information about status.
32       */
33      public static final ArtifactStatus NONE = new ArtifactStatus("none", 0);
34  
35      /**
36       * No trust - information was generated with defaults.
37       */
38      public static final ArtifactStatus GENERATED = new ArtifactStatus("generated", 1);
39  
40      /**
41       * Low trust - was converted from the Maven 1.x repository.
42       */
43      public static final ArtifactStatus CONVERTED = new ArtifactStatus("converted", 2);
44  
45      /**
46       * Moderate trust - it was deployed directly from a partner.
47       */
48      public static final ArtifactStatus PARTNER = new ArtifactStatus("partner", 3);
49  
50      /**
51       * Moderate trust - it was deployed directly by a user.
52       */
53      public static final ArtifactStatus DEPLOYED = new ArtifactStatus("deployed", 4);
54  
55      /**
56       * Trusted, as it has had its data verified by hand.
57       */
58      public static final ArtifactStatus VERIFIED = new ArtifactStatus("verified", 5);
59  
60      private final int rank;
61  
62      private final String key;
63  
64      private static Map<String, ArtifactStatus> map;
65  
66      private ArtifactStatus(String key, int rank) {
67          this.rank = rank;
68          this.key = key;
69  
70          if (map == null) {
71              map = new HashMap<>();
72          }
73          map.put(key, this);
74      }
75  
76      public static ArtifactStatus valueOf(String status) {
77          ArtifactStatus retVal = null;
78  
79          if (status != null) {
80              retVal = map.get(status);
81          }
82  
83          return retVal != null ? retVal : NONE;
84      }
85  
86      public boolean equals(Object o) {
87          if (this == o) {
88              return true;
89          }
90          if (o == null || getClass() != o.getClass()) {
91              return false;
92          }
93  
94          final ArtifactStatus that = (ArtifactStatus) o;
95  
96          return rank == that.rank;
97      }
98  
99      public int hashCode() {
100         return rank;
101     }
102 
103     public String toString() {
104         return key;
105     }
106 
107     public int compareTo(ArtifactStatus s) {
108         return rank - s.rank;
109     }
110 }