| 1 | |
package org.apache.maven.artifact; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
import java.util.HashMap; |
| 23 | |
import java.util.Map; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public final class ArtifactStatus |
| 32 | |
implements Comparable |
| 33 | |
{ |
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | 0 | public static final ArtifactStatus NONE = new ArtifactStatus( "none", 0 ); |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | 0 | public static final ArtifactStatus GENERATED = new ArtifactStatus( "generated", 1 ); |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | 0 | public static final ArtifactStatus CONVERTED = new ArtifactStatus( "converted", 2 ); |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | 0 | public static final ArtifactStatus PARTNER = new ArtifactStatus( "partner", 3 ); |
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | 0 | public static final ArtifactStatus DEPLOYED = new ArtifactStatus( "deployed", 4 ); |
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 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 | |
} |