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