1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.model.profile;
20
21 import java.io.File;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Properties;
26
27 import static java.util.stream.Collectors.collectingAndThen;
28 import static java.util.stream.Collectors.toMap;
29
30
31
32
33
34
35 @Deprecated(since = "4.0.0")
36 public class DefaultProfileActivationContext implements ProfileActivationContext {
37
38 private List<String> activeProfileIds = Collections.emptyList();
39
40 private List<String> inactiveProfileIds = Collections.emptyList();
41
42 private Map<String, String> systemProperties = Collections.emptyMap();
43
44 private Map<String, String> userProperties = Collections.emptyMap();
45
46 private Map<String, String> projectProperties = Collections.emptyMap();
47
48 private File projectDirectory;
49
50 @Override
51 public List<String> getActiveProfileIds() {
52 return activeProfileIds;
53 }
54
55
56
57
58
59
60
61 public DefaultProfileActivationContext setActiveProfileIds(List<String> activeProfileIds) {
62 if (activeProfileIds != null) {
63 this.activeProfileIds = Collections.unmodifiableList(activeProfileIds);
64 } else {
65 this.activeProfileIds = Collections.emptyList();
66 }
67
68 return this;
69 }
70
71 @Override
72 public List<String> getInactiveProfileIds() {
73 return inactiveProfileIds;
74 }
75
76
77
78
79
80
81
82 public DefaultProfileActivationContext setInactiveProfileIds(List<String> inactiveProfileIds) {
83 if (inactiveProfileIds != null) {
84 this.inactiveProfileIds = Collections.unmodifiableList(inactiveProfileIds);
85 } else {
86 this.inactiveProfileIds = Collections.emptyList();
87 }
88
89 return this;
90 }
91
92 @Override
93 public Map<String, String> getSystemProperties() {
94 return systemProperties;
95 }
96
97
98
99
100
101
102
103
104 @SuppressWarnings("unchecked")
105 public DefaultProfileActivationContext setSystemProperties(Properties systemProperties) {
106 if (systemProperties != null) {
107 this.systemProperties = Collections.unmodifiableMap((Map) systemProperties);
108 } else {
109 this.systemProperties = Collections.emptyMap();
110 }
111
112 return this;
113 }
114
115
116
117
118
119
120
121
122 public DefaultProfileActivationContext setSystemProperties(Map<String, String> systemProperties) {
123 if (systemProperties != null) {
124 this.systemProperties = Collections.unmodifiableMap(systemProperties);
125 } else {
126 this.systemProperties = Collections.emptyMap();
127 }
128
129 return this;
130 }
131
132 @Override
133 public Map<String, String> getUserProperties() {
134 return userProperties;
135 }
136
137
138
139
140
141
142
143
144
145 @SuppressWarnings("unchecked")
146 public DefaultProfileActivationContext setUserProperties(Properties userProperties) {
147 if (userProperties != null) {
148 this.userProperties = Collections.unmodifiableMap((Map) userProperties);
149 } else {
150 this.userProperties = Collections.emptyMap();
151 }
152
153 return this;
154 }
155
156
157
158
159
160
161
162
163
164 public DefaultProfileActivationContext setUserProperties(Map<String, String> userProperties) {
165 if (userProperties != null) {
166 this.userProperties = Collections.unmodifiableMap(userProperties);
167 } else {
168 this.userProperties = Collections.emptyMap();
169 }
170
171 return this;
172 }
173
174 @Override
175 public File getProjectDirectory() {
176 return projectDirectory;
177 }
178
179
180
181
182
183
184
185
186 public DefaultProfileActivationContext setProjectDirectory(File projectDirectory) {
187 this.projectDirectory = projectDirectory;
188
189 return this;
190 }
191
192 @Override
193 public Map<String, String> getProjectProperties() {
194 return projectProperties;
195 }
196
197 public DefaultProfileActivationContext setProjectProperties(Properties projectProperties) {
198 if (projectProperties != null) {
199 this.projectProperties = projectProperties.entrySet().stream()
200 .collect(collectingAndThen(
201 toMap(e -> String.valueOf(e.getKey()), e -> String.valueOf(e.getValue())),
202 Collections::unmodifiableMap));
203 } else {
204 this.projectProperties = Collections.emptyMap();
205 }
206
207 return this;
208 }
209 }