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
23
24
25
26
27
28
29
30 public enum ArtifactScopeEnum
31 {
32 compile( 1 ), test( 2 ), runtime( 3 ), provided( 4 ), system( 5 ), runtime_plus_system( 6 );
33
34 public static final ArtifactScopeEnum DEFAULT_SCOPE = compile;
35
36 private int id;
37
38
39 ArtifactScopeEnum( int id )
40 {
41 this.id = id;
42 }
43
44 int getId()
45 {
46 return id;
47 }
48
49
50
51
52
53 public static final ArtifactScopeEnum checkScope( ArtifactScopeEnum scope )
54 {
55 return scope == null ? DEFAULT_SCOPE : scope;
56 }
57
58
59
60
61
62 public String getScope()
63 {
64 if ( id == 1 )
65 {
66 return Artifact.SCOPE_COMPILE;
67 }
68 else if ( id == 2 )
69 {
70 return Artifact.SCOPE_TEST;
71
72 }
73 else if ( id == 3 )
74 {
75 return Artifact.SCOPE_RUNTIME;
76
77 }
78 else if ( id == 4 )
79 {
80 return Artifact.SCOPE_PROVIDED;
81 }
82 else if ( id == 5 )
83 {
84 return Artifact.SCOPE_SYSTEM;
85 }
86 else
87 {
88 return Artifact.SCOPE_RUNTIME_PLUS_SYSTEM;
89 }
90 }
91
92 private static final ArtifactScopeEnum [][][] COMPLIANCY_SETS = {
93 { { compile }, { compile, provided, system } }
94 , { { test }, { compile, test, provided, system } }
95 , { { runtime }, { compile, runtime, system } }
96 , { { provided }, { compile, test, provided } }
97 };
98
99
100
101
102
103
104
105 public boolean encloses( ArtifactScopeEnum scope )
106 {
107 final ArtifactScopeEnum s = checkScope( scope );
108
109
110 if ( id == system.id )
111 {
112 return scope.id == system.id;
113 }
114
115 for ( ArtifactScopeEnum[][] set : COMPLIANCY_SETS )
116 {
117 if ( id == set[0][0].id )
118 {
119 for ( ArtifactScopeEnum ase : set[1] )
120 {
121 if ( s.id == ase.id )
122 {
123 return true;
124 }
125 }
126 break;
127 }
128 }
129 return false;
130 }
131 }