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