1 package org.apache.maven.model.profile;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.Collections;
24 import java.util.Enumeration;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Properties;
29
30
31
32
33
34
35 public class DefaultProfileActivationContext
36 implements ProfileActivationContext
37 {
38
39 private List<String> activeProfileIds = Collections.emptyList();
40
41 private List<String> inactiveProfileIds = Collections.emptyList();
42
43 private Map<String, String> systemProperties = Collections.emptyMap();
44
45 private Map<String, String> userProperties = Collections.emptyMap();
46
47 private Map<String, String> projectProperties = Collections.emptyMap();
48
49 private File projectDirectory;
50
51 public List<String> getActiveProfileIds()
52 {
53 return activeProfileIds;
54 }
55
56
57
58
59
60
61
62 public DefaultProfileActivationContext setActiveProfileIds( List<String> activeProfileIds )
63 {
64 if ( activeProfileIds != null )
65 {
66 this.activeProfileIds = Collections.unmodifiableList( activeProfileIds );
67 }
68 else
69 {
70 this.activeProfileIds = Collections.emptyList();
71 }
72
73 return this;
74 }
75
76 public List<String> getInactiveProfileIds()
77 {
78 return inactiveProfileIds;
79 }
80
81
82
83
84
85
86
87 public DefaultProfileActivationContext setInactiveProfileIds( List<String> inactiveProfileIds )
88 {
89 if ( inactiveProfileIds != null )
90 {
91 this.inactiveProfileIds = Collections.unmodifiableList( inactiveProfileIds );
92 }
93 else
94 {
95 this.inactiveProfileIds = Collections.emptyList();
96 }
97
98 return this;
99 }
100
101 public Map<String, String> getSystemProperties()
102 {
103 return systemProperties;
104 }
105
106
107
108
109
110
111
112
113 @SuppressWarnings( "unchecked" )
114 public DefaultProfileActivationContext setSystemProperties( Properties systemProperties )
115 {
116 if ( systemProperties != null )
117 {
118 this.systemProperties = Collections.unmodifiableMap( (Map) systemProperties );
119 }
120 else
121 {
122 this.systemProperties = Collections.emptyMap();
123 }
124
125 return this;
126 }
127
128
129
130
131
132
133
134
135 public DefaultProfileActivationContext setSystemProperties( Map<String, String> systemProperties )
136 {
137 if ( systemProperties != null )
138 {
139 this.systemProperties = Collections.unmodifiableMap( systemProperties );
140 }
141 else
142 {
143 this.systemProperties = Collections.emptyMap();
144 }
145
146 return this;
147 }
148
149 public Map<String, String> getUserProperties()
150 {
151 return userProperties;
152 }
153
154
155
156
157
158
159
160
161
162 @SuppressWarnings( "unchecked" )
163 public DefaultProfileActivationContext setUserProperties( Properties userProperties )
164 {
165 if ( userProperties != null )
166 {
167 this.userProperties = Collections.unmodifiableMap( (Map) userProperties );
168 }
169 else
170 {
171 this.userProperties = Collections.emptyMap();
172 }
173
174 return this;
175 }
176
177
178
179
180
181
182
183
184
185 public DefaultProfileActivationContext setUserProperties( Map<String, String> userProperties )
186 {
187 if ( userProperties != null )
188 {
189 this.userProperties = Collections.unmodifiableMap( userProperties );
190 }
191 else
192 {
193 this.userProperties = Collections.emptyMap();
194 }
195
196 return this;
197 }
198
199 public File getProjectDirectory()
200 {
201 return projectDirectory;
202 }
203
204
205
206
207
208
209
210
211 public DefaultProfileActivationContext setProjectDirectory( File projectDirectory )
212 {
213 this.projectDirectory = projectDirectory;
214
215 return this;
216 }
217
218 public Map<String, String> getProjectProperties()
219 {
220 return projectProperties;
221 }
222
223 public DefaultProfileActivationContext setProjectProperties( Properties projectProperties )
224 {
225 if ( projectProperties != null )
226 {
227
228 this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) );
229 }
230 else
231 {
232 this.projectProperties = Collections.emptyMap();
233 }
234
235 return this;
236 }
237
238 private Map<String, String> toMap( Properties properties )
239 {
240 if ( properties == null )
241 {
242 return Collections.emptyMap();
243 }
244 Map<String, String> map = new HashMap<String, String>();
245 Enumeration keys = properties.keys();
246 while ( keys.hasMoreElements() )
247 {
248 String key = (String) keys.nextElement();
249 map.put( key, properties.getProperty( key ) );
250 }
251 return map;
252 }
253 }