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 import java.util.stream.Collectors;
27
28
29
30
31
32
33 @Deprecated(since = "4.0.0")
34 public class DefaultProfileActivationContext implements ProfileActivationContext {
35
36 private List<String> activeProfileIds = Collections.emptyList();
37
38 private List<String> inactiveProfileIds = Collections.emptyList();
39
40 private Map<String, String> systemProperties = Collections.emptyMap();
41
42 private Map<String, String> userProperties = Collections.emptyMap();
43
44 private Map<String, String> projectProperties = Collections.emptyMap();
45
46 private File projectDirectory;
47
48 @Override
49 public List<String> getActiveProfileIds() {
50 return activeProfileIds;
51 }
52
53
54
55
56
57
58
59 public DefaultProfileActivationContext setActiveProfileIds(List<String> activeProfileIds) {
60 this.activeProfileIds = unmodifiable(activeProfileIds);
61 return this;
62 }
63
64 @Override
65 public List<String> getInactiveProfileIds() {
66 return inactiveProfileIds;
67 }
68
69
70
71
72
73
74
75 public DefaultProfileActivationContext setInactiveProfileIds(List<String> inactiveProfileIds) {
76 this.inactiveProfileIds = unmodifiable(inactiveProfileIds);
77 return this;
78 }
79
80 @Override
81 public Map<String, String> getSystemProperties() {
82 return systemProperties;
83 }
84
85
86
87
88
89
90
91
92 @SuppressWarnings("unchecked")
93 public DefaultProfileActivationContext setSystemProperties(Properties systemProperties) {
94 return setSystemProperties(toMap(systemProperties));
95 }
96
97
98
99
100
101
102
103
104 public DefaultProfileActivationContext setSystemProperties(Map<String, String> systemProperties) {
105 this.systemProperties = unmodifiable(systemProperties);
106 return this;
107 }
108
109 @Override
110 public Map<String, String> getUserProperties() {
111 return userProperties;
112 }
113
114
115
116
117
118
119
120
121
122 @SuppressWarnings("unchecked")
123 public DefaultProfileActivationContext setUserProperties(Properties userProperties) {
124 return setUserProperties(toMap(userProperties));
125 }
126
127
128
129
130
131
132
133
134
135 public DefaultProfileActivationContext setUserProperties(Map<String, String> userProperties) {
136 this.userProperties = unmodifiable(userProperties);
137 return this;
138 }
139
140 @Override
141 public File getProjectDirectory() {
142 return projectDirectory;
143 }
144
145
146
147
148
149
150
151
152 public DefaultProfileActivationContext setProjectDirectory(File projectDirectory) {
153 this.projectDirectory = projectDirectory;
154
155 return this;
156 }
157
158 @Override
159 public Map<String, String> getProjectProperties() {
160 return projectProperties;
161 }
162
163 public DefaultProfileActivationContext setProjectProperties(Properties projectProperties) {
164 return setProjectProperties(toMap(projectProperties));
165 }
166
167 public DefaultProfileActivationContext setProjectProperties(Map<String, String> projectProperties) {
168 this.projectProperties = unmodifiable(projectProperties);
169
170 return this;
171 }
172
173 private static List<String> unmodifiable(List<String> list) {
174 return list != null ? Collections.unmodifiableList(list) : Collections.emptyList();
175 }
176
177 private static Map<String, String> unmodifiable(Map<String, String> map) {
178 return map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap();
179 }
180
181 private static Map<String, String> toMap(Properties properties) {
182 if (properties != null && !properties.isEmpty()) {
183 return properties.entrySet().stream()
184 .collect(Collectors.toMap(e -> String.valueOf(e.getKey()), e -> String.valueOf(e.getValue())));
185
186 } else {
187 return null;
188 }
189 }
190 }