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