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
54
55
56 public static ArtifactScopeEnum checkScope( ArtifactScopeEnum scope )
57 {
58 return scope == null ? DEFAULT_SCOPE : scope;
59 }
60
61
62
63
64
65 public String getScope()
66 {
67 if ( id == 1 )
68 {
69 return Artifact.SCOPE_COMPILE;
70 }
71 else if ( id == 2 )
72 {
73 return Artifact.SCOPE_TEST;
74
75 }
76 else if ( id == 3 )
77 {
78 return Artifact.SCOPE_RUNTIME;
79
80 }
81 else if ( id == 4 )
82 {
83 return Artifact.SCOPE_PROVIDED;
84 }
85 else if ( id == 5 )
86 {
87 return Artifact.SCOPE_SYSTEM;
88 }
89 else
90 {
91 return Artifact.SCOPE_RUNTIME_PLUS_SYSTEM;
92 }
93 }
94
95 private static final ArtifactScopeEnum [][][] COMPLIANCY_SETS = {
96 { { compile }, { compile, provided, system } }
97 , { { test }, { compile, test, provided, system } }
98 , { { runtime }, { compile, runtime, system } }
99 , { { provided }, { compile, test, provided } }
100 };
101
102
103
104
105
106
107
108 public boolean encloses( ArtifactScopeEnum scope )
109 {
110 final ArtifactScopeEnum s = checkScope( scope );
111
112
113 if ( id == system.id )
114 {
115 return scope.id == system.id;
116 }
117
118 for ( ArtifactScopeEnum[][] set : COMPLIANCY_SETS )
119 {
120 if ( id == set[0][0].id )
121 {
122 for ( ArtifactScopeEnum ase : set[1] )
123 {
124 if ( s.id == ase.id )
125 {
126 return true;
127 }
128 }
129 break;
130 }
131 }
132 return false;
133 }
134 }