1
2
3
4
5 package org.apache.maven.settings.v4;
6
7 import java.io.ObjectStreamException;
8 import java.util.AbstractList;
9 import java.util.ArrayList;
10 import java.util.Collection;
11 import java.util.HashMap;
12 import java.util.Iterator;
13 import java.util.LinkedHashMap;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.Properties;
17 import java.util.Objects;
18 import java.util.function.BinaryOperator;
19 import java.util.function.Function;
20 import java.util.function.Supplier;
21 import java.util.stream.Collectors;
22
23 import org.apache.maven.api.annotations.Generated;
24 import org.apache.maven.api.xml.XmlNode;
25 import org.apache.maven.api.settings.TrackableBase;
26 import org.apache.maven.api.settings.IdentifiableBase;
27 import org.apache.maven.api.settings.Settings;
28 import org.apache.maven.api.settings.Proxy;
29 import org.apache.maven.api.settings.Server;
30 import org.apache.maven.api.settings.Mirror;
31 import org.apache.maven.api.settings.Profile;
32 import org.apache.maven.api.settings.Activation;
33 import org.apache.maven.api.settings.RepositoryBase;
34 import org.apache.maven.api.settings.Repository;
35 import org.apache.maven.api.settings.RepositoryPolicy;
36 import org.apache.maven.api.settings.ActivationProperty;
37 import org.apache.maven.api.settings.ActivationOS;
38 import org.apache.maven.api.settings.ActivationFile;
39 import org.apache.maven.api.settings.InputLocation;
40 import org.apache.maven.api.settings.InputSource;
41 import org.apache.maven.internal.xml.XmlNodeImpl;
42
43 @Generated
44 public class SettingsTransformer {
45
46 private final Function<String, String> transformer;
47
48 public SettingsTransformer(Function<String, String> transformer) {
49 this.transformer = transformer;
50 }
51
52
53
54
55 public Settings visit(Settings target) {
56 Objects.requireNonNull(target, "target cannot be null");
57 return transformSettings(target);
58 }
59
60
61
62
63 protected String transform(String value) {
64 return transformer.apply(value);
65 }
66
67 protected TrackableBase transformTrackableBase(TrackableBase target) {
68 if (target == null) {
69 return null;
70 }
71 Supplier<TrackableBase.Builder> creator = () -> TrackableBase.newBuilder(target);
72 TrackableBase.Builder builder = null;
73 return builder != null ? builder.build() : target;
74 }
75
76
77 protected IdentifiableBase transformIdentifiableBase(IdentifiableBase target) {
78 if (target == null) {
79 return null;
80 }
81 Supplier<IdentifiableBase.Builder> creator = () -> IdentifiableBase.newBuilder(target);
82 IdentifiableBase.Builder builder = null;
83 builder = (IdentifiableBase.Builder) transformIdentifiableBase_Id(creator, builder, target);
84 return builder != null ? builder.build() : target;
85 }
86
87 protected IdentifiableBase.Builder transformIdentifiableBase_Id(Supplier<? extends IdentifiableBase.Builder> creator, IdentifiableBase.Builder builder, IdentifiableBase target) {
88 String oldVal = target.getId();
89 String newVal = transform(oldVal);
90 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
91 }
92
93 protected Settings transformSettings(Settings target) {
94 if (target == null) {
95 return null;
96 }
97 Supplier<Settings.Builder> creator = () -> Settings.newBuilder(target);
98 Settings.Builder builder = null;
99 builder = (Settings.Builder) transformSettings_LocalRepository(creator, builder, target);
100 builder = (Settings.Builder) transformSettings_InteractiveMode(creator, builder, target);
101 builder = (Settings.Builder) transformSettings_UsePluginRegistry(creator, builder, target);
102 builder = (Settings.Builder) transformSettings_Offline(creator, builder, target);
103 builder = (Settings.Builder) transformSettings_Proxies(creator, builder, target);
104 builder = (Settings.Builder) transformSettings_Servers(creator, builder, target);
105 builder = (Settings.Builder) transformSettings_Mirrors(creator, builder, target);
106 builder = (Settings.Builder) transformSettings_Repositories(creator, builder, target);
107 builder = (Settings.Builder) transformSettings_PluginRepositories(creator, builder, target);
108 builder = (Settings.Builder) transformSettings_Profiles(creator, builder, target);
109 builder = (Settings.Builder) transformSettings_ActiveProfiles(creator, builder, target);
110 builder = (Settings.Builder) transformSettings_PluginGroups(creator, builder, target);
111 return builder != null ? builder.build() : target;
112 }
113
114 protected Settings.Builder transformSettings_LocalRepository(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
115 String oldVal = target.getLocalRepository();
116 String newVal = transform(oldVal);
117 return newVal != oldVal ? (builder != null ? builder : creator.get()).localRepository(newVal) : builder;
118 }
119 protected Settings.Builder transformSettings_InteractiveMode(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
120
121 return builder;
122 }
123 protected Settings.Builder transformSettings_UsePluginRegistry(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
124
125 return builder;
126 }
127 protected Settings.Builder transformSettings_Offline(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
128
129 return builder;
130 }
131 protected Settings.Builder transformSettings_Proxies(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
132 List<Proxy> oldVal = target.getProxies();
133 List<Proxy> newVal = transform(oldVal, this::transformProxy);
134 return newVal != oldVal ? (builder != null ? builder : creator.get()).proxies(newVal) : builder;
135 }
136 protected Settings.Builder transformSettings_Servers(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
137 List<Server> oldVal = target.getServers();
138 List<Server> newVal = transform(oldVal, this::transformServer);
139 return newVal != oldVal ? (builder != null ? builder : creator.get()).servers(newVal) : builder;
140 }
141 protected Settings.Builder transformSettings_Mirrors(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
142 List<Mirror> oldVal = target.getMirrors();
143 List<Mirror> newVal = transform(oldVal, this::transformMirror);
144 return newVal != oldVal ? (builder != null ? builder : creator.get()).mirrors(newVal) : builder;
145 }
146 protected Settings.Builder transformSettings_Repositories(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
147 List<Repository> oldVal = target.getRepositories();
148 List<Repository> newVal = transform(oldVal, this::transformRepository);
149 return newVal != oldVal ? (builder != null ? builder : creator.get()).repositories(newVal) : builder;
150 }
151 protected Settings.Builder transformSettings_PluginRepositories(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
152 List<Repository> oldVal = target.getPluginRepositories();
153 List<Repository> newVal = transform(oldVal, this::transformRepository);
154 return newVal != oldVal ? (builder != null ? builder : creator.get()).pluginRepositories(newVal) : builder;
155 }
156 protected Settings.Builder transformSettings_Profiles(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
157 List<Profile> oldVal = target.getProfiles();
158 List<Profile> newVal = transform(oldVal, this::transformProfile);
159 return newVal != oldVal ? (builder != null ? builder : creator.get()).profiles(newVal) : builder;
160 }
161 protected Settings.Builder transformSettings_ActiveProfiles(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
162 List<String> oldVal = target.getActiveProfiles();
163 List<String> newVal = transform(oldVal, this::transform);
164 return newVal != oldVal ? (builder != null ? builder : creator.get()).activeProfiles(newVal) : builder;
165 }
166 protected Settings.Builder transformSettings_PluginGroups(Supplier<? extends Settings.Builder> creator, Settings.Builder builder, Settings target) {
167 List<String> oldVal = target.getPluginGroups();
168 List<String> newVal = transform(oldVal, this::transform);
169 return newVal != oldVal ? (builder != null ? builder : creator.get()).pluginGroups(newVal) : builder;
170 }
171
172 protected Proxy transformProxy(Proxy target) {
173 if (target == null) {
174 return null;
175 }
176 Supplier<Proxy.Builder> creator = () -> Proxy.newBuilder(target);
177 Proxy.Builder builder = null;
178 builder = (Proxy.Builder) transformProxy_ActiveString(creator, builder, target);
179 builder = (Proxy.Builder) transformProxy_Protocol(creator, builder, target);
180 builder = (Proxy.Builder) transformProxy_Username(creator, builder, target);
181 builder = (Proxy.Builder) transformProxy_Password(creator, builder, target);
182 builder = (Proxy.Builder) transformProxy_PortString(creator, builder, target);
183 builder = (Proxy.Builder) transformProxy_Host(creator, builder, target);
184 builder = (Proxy.Builder) transformProxy_NonProxyHosts(creator, builder, target);
185 builder = (Proxy.Builder) transformIdentifiableBase_Id(creator, builder, target);
186 return builder != null ? builder.build() : target;
187 }
188
189 protected Proxy.Builder transformProxy_ActiveString(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
190 String oldVal = target.getActiveString();
191 String newVal = transform(oldVal);
192 return newVal != oldVal ? (builder != null ? builder : creator.get()).activeString(newVal) : builder;
193 }
194 protected Proxy.Builder transformProxy_Protocol(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
195 String oldVal = target.getProtocol();
196 String newVal = transform(oldVal);
197 return newVal != oldVal ? (builder != null ? builder : creator.get()).protocol(newVal) : builder;
198 }
199 protected Proxy.Builder transformProxy_Username(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
200 String oldVal = target.getUsername();
201 String newVal = transform(oldVal);
202 return newVal != oldVal ? (builder != null ? builder : creator.get()).username(newVal) : builder;
203 }
204 protected Proxy.Builder transformProxy_Password(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
205 String oldVal = target.getPassword();
206 String newVal = transform(oldVal);
207 return newVal != oldVal ? (builder != null ? builder : creator.get()).password(newVal) : builder;
208 }
209 protected Proxy.Builder transformProxy_PortString(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
210 String oldVal = target.getPortString();
211 String newVal = transform(oldVal);
212 return newVal != oldVal ? (builder != null ? builder : creator.get()).portString(newVal) : builder;
213 }
214 protected Proxy.Builder transformProxy_Host(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
215 String oldVal = target.getHost();
216 String newVal = transform(oldVal);
217 return newVal != oldVal ? (builder != null ? builder : creator.get()).host(newVal) : builder;
218 }
219 protected Proxy.Builder transformProxy_NonProxyHosts(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
220 String oldVal = target.getNonProxyHosts();
221 String newVal = transform(oldVal);
222 return newVal != oldVal ? (builder != null ? builder : creator.get()).nonProxyHosts(newVal) : builder;
223 }
224 protected Proxy.Builder transformProxy_Id(Supplier<? extends Proxy.Builder> creator, Proxy.Builder builder, Proxy target) {
225 String oldVal = target.getId();
226 String newVal = transform(oldVal);
227 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
228 }
229
230 protected Server transformServer(Server target) {
231 if (target == null) {
232 return null;
233 }
234 Supplier<Server.Builder> creator = () -> Server.newBuilder(target);
235 Server.Builder builder = null;
236 builder = (Server.Builder) transformServer_Username(creator, builder, target);
237 builder = (Server.Builder) transformServer_Password(creator, builder, target);
238 builder = (Server.Builder) transformServer_PrivateKey(creator, builder, target);
239 builder = (Server.Builder) transformServer_Passphrase(creator, builder, target);
240 builder = (Server.Builder) transformServer_FilePermissions(creator, builder, target);
241 builder = (Server.Builder) transformServer_DirectoryPermissions(creator, builder, target);
242 builder = (Server.Builder) transformServer_Configuration(creator, builder, target);
243 builder = (Server.Builder) transformIdentifiableBase_Id(creator, builder, target);
244 return builder != null ? builder.build() : target;
245 }
246
247 protected Server.Builder transformServer_Username(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
248 String oldVal = target.getUsername();
249 String newVal = transform(oldVal);
250 return newVal != oldVal ? (builder != null ? builder : creator.get()).username(newVal) : builder;
251 }
252 protected Server.Builder transformServer_Password(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
253 String oldVal = target.getPassword();
254 String newVal = transform(oldVal);
255 return newVal != oldVal ? (builder != null ? builder : creator.get()).password(newVal) : builder;
256 }
257 protected Server.Builder transformServer_PrivateKey(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
258 String oldVal = target.getPrivateKey();
259 String newVal = transform(oldVal);
260 return newVal != oldVal ? (builder != null ? builder : creator.get()).privateKey(newVal) : builder;
261 }
262 protected Server.Builder transformServer_Passphrase(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
263 String oldVal = target.getPassphrase();
264 String newVal = transform(oldVal);
265 return newVal != oldVal ? (builder != null ? builder : creator.get()).passphrase(newVal) : builder;
266 }
267 protected Server.Builder transformServer_FilePermissions(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
268 String oldVal = target.getFilePermissions();
269 String newVal = transform(oldVal);
270 return newVal != oldVal ? (builder != null ? builder : creator.get()).filePermissions(newVal) : builder;
271 }
272 protected Server.Builder transformServer_DirectoryPermissions(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
273 String oldVal = target.getDirectoryPermissions();
274 String newVal = transform(oldVal);
275 return newVal != oldVal ? (builder != null ? builder : creator.get()).directoryPermissions(newVal) : builder;
276 }
277 protected Server.Builder transformServer_Configuration(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
278 XmlNode oldVal = target.getConfiguration();
279 XmlNode newVal = transform(oldVal);
280 return newVal != oldVal ? (builder != null ? builder : creator.get()).configuration(newVal) : builder;
281 }
282 protected Server.Builder transformServer_Id(Supplier<? extends Server.Builder> creator, Server.Builder builder, Server target) {
283 String oldVal = target.getId();
284 String newVal = transform(oldVal);
285 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
286 }
287
288 protected Mirror transformMirror(Mirror target) {
289 if (target == null) {
290 return null;
291 }
292 Supplier<Mirror.Builder> creator = () -> Mirror.newBuilder(target);
293 Mirror.Builder builder = null;
294 builder = (Mirror.Builder) transformMirror_MirrorOf(creator, builder, target);
295 builder = (Mirror.Builder) transformMirror_Name(creator, builder, target);
296 builder = (Mirror.Builder) transformMirror_Url(creator, builder, target);
297 builder = (Mirror.Builder) transformMirror_Layout(creator, builder, target);
298 builder = (Mirror.Builder) transformMirror_MirrorOfLayouts(creator, builder, target);
299 builder = (Mirror.Builder) transformMirror_Blocked(creator, builder, target);
300 builder = (Mirror.Builder) transformIdentifiableBase_Id(creator, builder, target);
301 return builder != null ? builder.build() : target;
302 }
303
304 protected Mirror.Builder transformMirror_MirrorOf(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
305 String oldVal = target.getMirrorOf();
306 String newVal = transform(oldVal);
307 return newVal != oldVal ? (builder != null ? builder : creator.get()).mirrorOf(newVal) : builder;
308 }
309 protected Mirror.Builder transformMirror_Name(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
310 String oldVal = target.getName();
311 String newVal = transform(oldVal);
312 return newVal != oldVal ? (builder != null ? builder : creator.get()).name(newVal) : builder;
313 }
314 protected Mirror.Builder transformMirror_Url(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
315 String oldVal = target.getUrl();
316 String newVal = transform(oldVal);
317 return newVal != oldVal ? (builder != null ? builder : creator.get()).url(newVal) : builder;
318 }
319 protected Mirror.Builder transformMirror_Layout(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
320 String oldVal = target.getLayout();
321 String newVal = transform(oldVal);
322 return newVal != oldVal ? (builder != null ? builder : creator.get()).layout(newVal) : builder;
323 }
324 protected Mirror.Builder transformMirror_MirrorOfLayouts(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
325 String oldVal = target.getMirrorOfLayouts();
326 String newVal = transform(oldVal);
327 return newVal != oldVal ? (builder != null ? builder : creator.get()).mirrorOfLayouts(newVal) : builder;
328 }
329 protected Mirror.Builder transformMirror_Blocked(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
330
331 return builder;
332 }
333 protected Mirror.Builder transformMirror_Id(Supplier<? extends Mirror.Builder> creator, Mirror.Builder builder, Mirror target) {
334 String oldVal = target.getId();
335 String newVal = transform(oldVal);
336 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
337 }
338
339 protected Profile transformProfile(Profile target) {
340 if (target == null) {
341 return null;
342 }
343 Supplier<Profile.Builder> creator = () -> Profile.newBuilder(target);
344 Profile.Builder builder = null;
345 builder = (Profile.Builder) transformProfile_Activation(creator, builder, target);
346 builder = (Profile.Builder) transformProfile_Properties(creator, builder, target);
347 builder = (Profile.Builder) transformProfile_Repositories(creator, builder, target);
348 builder = (Profile.Builder) transformProfile_PluginRepositories(creator, builder, target);
349 builder = (Profile.Builder) transformIdentifiableBase_Id(creator, builder, target);
350 return builder != null ? builder.build() : target;
351 }
352
353 protected Profile.Builder transformProfile_Activation(Supplier<? extends Profile.Builder> creator, Profile.Builder builder, Profile target) {
354 Activation oldVal = target.getActivation();
355 Activation newVal = transformActivation(oldVal);
356 return newVal != oldVal ? (builder != null ? builder : creator.get()).activation(newVal) : builder;
357 }
358 protected Profile.Builder transformProfile_Properties(Supplier<? extends Profile.Builder> creator, Profile.Builder builder, Profile target) {
359 Map<String, String> props = target.getProperties();
360 Map<String, String> newProps = null;
361 for (Map.Entry<String, String> entry : props.entrySet()) {
362 String newVal = transform(entry.getValue());
363 if (newVal != null && newVal != entry.getValue()) {
364 if (newProps == null) {
365 newProps = new HashMap<>();
366 newProps.putAll(props);
367 builder = builder != null ? builder : creator.get();
368 builder.properties(newProps);
369 }
370 newProps.put(entry.getKey(), newVal);
371 }
372 }
373 return builder;
374 }
375 protected Profile.Builder transformProfile_Repositories(Supplier<? extends Profile.Builder> creator, Profile.Builder builder, Profile target) {
376 List<Repository> oldVal = target.getRepositories();
377 List<Repository> newVal = transform(oldVal, this::transformRepository);
378 return newVal != oldVal ? (builder != null ? builder : creator.get()).repositories(newVal) : builder;
379 }
380 protected Profile.Builder transformProfile_PluginRepositories(Supplier<? extends Profile.Builder> creator, Profile.Builder builder, Profile target) {
381 List<Repository> oldVal = target.getPluginRepositories();
382 List<Repository> newVal = transform(oldVal, this::transformRepository);
383 return newVal != oldVal ? (builder != null ? builder : creator.get()).pluginRepositories(newVal) : builder;
384 }
385 protected Profile.Builder transformProfile_Id(Supplier<? extends Profile.Builder> creator, Profile.Builder builder, Profile target) {
386 String oldVal = target.getId();
387 String newVal = transform(oldVal);
388 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
389 }
390
391 protected Activation transformActivation(Activation target) {
392 if (target == null) {
393 return null;
394 }
395 Supplier<Activation.Builder> creator = () -> Activation.newBuilder(target);
396 Activation.Builder builder = null;
397 builder = (Activation.Builder) transformActivation_ActiveByDefault(creator, builder, target);
398 builder = (Activation.Builder) transformActivation_Jdk(creator, builder, target);
399 builder = (Activation.Builder) transformActivation_Os(creator, builder, target);
400 builder = (Activation.Builder) transformActivation_Property(creator, builder, target);
401 builder = (Activation.Builder) transformActivation_File(creator, builder, target);
402 builder = (Activation.Builder) transformActivation_Packaging(creator, builder, target);
403 return builder != null ? builder.build() : target;
404 }
405
406 protected Activation.Builder transformActivation_ActiveByDefault(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
407
408 return builder;
409 }
410 protected Activation.Builder transformActivation_Jdk(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
411 String oldVal = target.getJdk();
412 String newVal = transform(oldVal);
413 return newVal != oldVal ? (builder != null ? builder : creator.get()).jdk(newVal) : builder;
414 }
415 protected Activation.Builder transformActivation_Os(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
416 ActivationOS oldVal = target.getOs();
417 ActivationOS newVal = transformActivationOS(oldVal);
418 return newVal != oldVal ? (builder != null ? builder : creator.get()).os(newVal) : builder;
419 }
420 protected Activation.Builder transformActivation_Property(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
421 ActivationProperty oldVal = target.getProperty();
422 ActivationProperty newVal = transformActivationProperty(oldVal);
423 return newVal != oldVal ? (builder != null ? builder : creator.get()).property(newVal) : builder;
424 }
425 protected Activation.Builder transformActivation_File(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
426 ActivationFile oldVal = target.getFile();
427 ActivationFile newVal = transformActivationFile(oldVal);
428 return newVal != oldVal ? (builder != null ? builder : creator.get()).file(newVal) : builder;
429 }
430 protected Activation.Builder transformActivation_Packaging(Supplier<? extends Activation.Builder> creator, Activation.Builder builder, Activation target) {
431 String oldVal = target.getPackaging();
432 String newVal = transform(oldVal);
433 return newVal != oldVal ? (builder != null ? builder : creator.get()).packaging(newVal) : builder;
434 }
435
436 protected RepositoryBase transformRepositoryBase(RepositoryBase target) {
437 if (target == null) {
438 return null;
439 }
440 Supplier<RepositoryBase.Builder> creator = () -> RepositoryBase.newBuilder(target);
441 RepositoryBase.Builder builder = null;
442 builder = (RepositoryBase.Builder) transformRepositoryBase_Name(creator, builder, target);
443 builder = (RepositoryBase.Builder) transformRepositoryBase_Url(creator, builder, target);
444 builder = (RepositoryBase.Builder) transformRepositoryBase_Layout(creator, builder, target);
445 builder = (RepositoryBase.Builder) transformIdentifiableBase_Id(creator, builder, target);
446 return builder != null ? builder.build() : target;
447 }
448
449 protected RepositoryBase.Builder transformRepositoryBase_Name(Supplier<? extends RepositoryBase.Builder> creator, RepositoryBase.Builder builder, RepositoryBase target) {
450 String oldVal = target.getName();
451 String newVal = transform(oldVal);
452 return newVal != oldVal ? (builder != null ? builder : creator.get()).name(newVal) : builder;
453 }
454 protected RepositoryBase.Builder transformRepositoryBase_Url(Supplier<? extends RepositoryBase.Builder> creator, RepositoryBase.Builder builder, RepositoryBase target) {
455 String oldVal = target.getUrl();
456 String newVal = transform(oldVal);
457 return newVal != oldVal ? (builder != null ? builder : creator.get()).url(newVal) : builder;
458 }
459 protected RepositoryBase.Builder transformRepositoryBase_Layout(Supplier<? extends RepositoryBase.Builder> creator, RepositoryBase.Builder builder, RepositoryBase target) {
460 String oldVal = target.getLayout();
461 String newVal = transform(oldVal);
462 return newVal != oldVal ? (builder != null ? builder : creator.get()).layout(newVal) : builder;
463 }
464 protected RepositoryBase.Builder transformRepositoryBase_Id(Supplier<? extends RepositoryBase.Builder> creator, RepositoryBase.Builder builder, RepositoryBase target) {
465 String oldVal = target.getId();
466 String newVal = transform(oldVal);
467 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
468 }
469
470 protected Repository transformRepository(Repository target) {
471 if (target == null) {
472 return null;
473 }
474 Supplier<Repository.Builder> creator = () -> Repository.newBuilder(target);
475 Repository.Builder builder = null;
476 builder = (Repository.Builder) transformRepository_Releases(creator, builder, target);
477 builder = (Repository.Builder) transformRepository_Snapshots(creator, builder, target);
478 builder = (Repository.Builder) transformRepositoryBase_Name(creator, builder, target);
479 builder = (Repository.Builder) transformRepositoryBase_Url(creator, builder, target);
480 builder = (Repository.Builder) transformRepositoryBase_Layout(creator, builder, target);
481 builder = (Repository.Builder) transformIdentifiableBase_Id(creator, builder, target);
482 return builder != null ? builder.build() : target;
483 }
484
485 protected Repository.Builder transformRepository_Releases(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
486 RepositoryPolicy oldVal = target.getReleases();
487 RepositoryPolicy newVal = transformRepositoryPolicy(oldVal);
488 return newVal != oldVal ? (builder != null ? builder : creator.get()).releases(newVal) : builder;
489 }
490 protected Repository.Builder transformRepository_Snapshots(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
491 RepositoryPolicy oldVal = target.getSnapshots();
492 RepositoryPolicy newVal = transformRepositoryPolicy(oldVal);
493 return newVal != oldVal ? (builder != null ? builder : creator.get()).snapshots(newVal) : builder;
494 }
495 protected Repository.Builder transformRepository_Name(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
496 String oldVal = target.getName();
497 String newVal = transform(oldVal);
498 return newVal != oldVal ? (builder != null ? builder : creator.get()).name(newVal) : builder;
499 }
500 protected Repository.Builder transformRepository_Url(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
501 String oldVal = target.getUrl();
502 String newVal = transform(oldVal);
503 return newVal != oldVal ? (builder != null ? builder : creator.get()).url(newVal) : builder;
504 }
505 protected Repository.Builder transformRepository_Layout(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
506 String oldVal = target.getLayout();
507 String newVal = transform(oldVal);
508 return newVal != oldVal ? (builder != null ? builder : creator.get()).layout(newVal) : builder;
509 }
510 protected Repository.Builder transformRepository_Id(Supplier<? extends Repository.Builder> creator, Repository.Builder builder, Repository target) {
511 String oldVal = target.getId();
512 String newVal = transform(oldVal);
513 return newVal != oldVal ? (builder != null ? builder : creator.get()).id(newVal) : builder;
514 }
515
516 protected RepositoryPolicy transformRepositoryPolicy(RepositoryPolicy target) {
517 if (target == null) {
518 return null;
519 }
520 Supplier<RepositoryPolicy.Builder> creator = () -> RepositoryPolicy.newBuilder(target);
521 RepositoryPolicy.Builder builder = null;
522 builder = (RepositoryPolicy.Builder) transformRepositoryPolicy_Enabled(creator, builder, target);
523 builder = (RepositoryPolicy.Builder) transformRepositoryPolicy_UpdatePolicy(creator, builder, target);
524 builder = (RepositoryPolicy.Builder) transformRepositoryPolicy_ChecksumPolicy(creator, builder, target);
525 return builder != null ? builder.build() : target;
526 }
527
528 protected RepositoryPolicy.Builder transformRepositoryPolicy_Enabled(Supplier<? extends RepositoryPolicy.Builder> creator, RepositoryPolicy.Builder builder, RepositoryPolicy target) {
529
530 return builder;
531 }
532 protected RepositoryPolicy.Builder transformRepositoryPolicy_UpdatePolicy(Supplier<? extends RepositoryPolicy.Builder> creator, RepositoryPolicy.Builder builder, RepositoryPolicy target) {
533 String oldVal = target.getUpdatePolicy();
534 String newVal = transform(oldVal);
535 return newVal != oldVal ? (builder != null ? builder : creator.get()).updatePolicy(newVal) : builder;
536 }
537 protected RepositoryPolicy.Builder transformRepositoryPolicy_ChecksumPolicy(Supplier<? extends RepositoryPolicy.Builder> creator, RepositoryPolicy.Builder builder, RepositoryPolicy target) {
538 String oldVal = target.getChecksumPolicy();
539 String newVal = transform(oldVal);
540 return newVal != oldVal ? (builder != null ? builder : creator.get()).checksumPolicy(newVal) : builder;
541 }
542
543 protected ActivationProperty transformActivationProperty(ActivationProperty target) {
544 if (target == null) {
545 return null;
546 }
547 Supplier<ActivationProperty.Builder> creator = () -> ActivationProperty.newBuilder(target);
548 ActivationProperty.Builder builder = null;
549 builder = (ActivationProperty.Builder) transformActivationProperty_Name(creator, builder, target);
550 builder = (ActivationProperty.Builder) transformActivationProperty_Value(creator, builder, target);
551 return builder != null ? builder.build() : target;
552 }
553
554 protected ActivationProperty.Builder transformActivationProperty_Name(Supplier<? extends ActivationProperty.Builder> creator, ActivationProperty.Builder builder, ActivationProperty target) {
555 String oldVal = target.getName();
556 String newVal = transform(oldVal);
557 return newVal != oldVal ? (builder != null ? builder : creator.get()).name(newVal) : builder;
558 }
559 protected ActivationProperty.Builder transformActivationProperty_Value(Supplier<? extends ActivationProperty.Builder> creator, ActivationProperty.Builder builder, ActivationProperty target) {
560 String oldVal = target.getValue();
561 String newVal = transform(oldVal);
562 return newVal != oldVal ? (builder != null ? builder : creator.get()).value(newVal) : builder;
563 }
564
565 protected ActivationOS transformActivationOS(ActivationOS target) {
566 if (target == null) {
567 return null;
568 }
569 Supplier<ActivationOS.Builder> creator = () -> ActivationOS.newBuilder(target);
570 ActivationOS.Builder builder = null;
571 builder = (ActivationOS.Builder) transformActivationOS_Name(creator, builder, target);
572 builder = (ActivationOS.Builder) transformActivationOS_Family(creator, builder, target);
573 builder = (ActivationOS.Builder) transformActivationOS_Arch(creator, builder, target);
574 builder = (ActivationOS.Builder) transformActivationOS_Version(creator, builder, target);
575 return builder != null ? builder.build() : target;
576 }
577
578 protected ActivationOS.Builder transformActivationOS_Name(Supplier<? extends ActivationOS.Builder> creator, ActivationOS.Builder builder, ActivationOS target) {
579 String oldVal = target.getName();
580 String newVal = transform(oldVal);
581 return newVal != oldVal ? (builder != null ? builder : creator.get()).name(newVal) : builder;
582 }
583 protected ActivationOS.Builder transformActivationOS_Family(Supplier<? extends ActivationOS.Builder> creator, ActivationOS.Builder builder, ActivationOS target) {
584 String oldVal = target.getFamily();
585 String newVal = transform(oldVal);
586 return newVal != oldVal ? (builder != null ? builder : creator.get()).family(newVal) : builder;
587 }
588 protected ActivationOS.Builder transformActivationOS_Arch(Supplier<? extends ActivationOS.Builder> creator, ActivationOS.Builder builder, ActivationOS target) {
589 String oldVal = target.getArch();
590 String newVal = transform(oldVal);
591 return newVal != oldVal ? (builder != null ? builder : creator.get()).arch(newVal) : builder;
592 }
593 protected ActivationOS.Builder transformActivationOS_Version(Supplier<? extends ActivationOS.Builder> creator, ActivationOS.Builder builder, ActivationOS target) {
594 String oldVal = target.getVersion();
595 String newVal = transform(oldVal);
596 return newVal != oldVal ? (builder != null ? builder : creator.get()).version(newVal) : builder;
597 }
598
599 protected ActivationFile transformActivationFile(ActivationFile target) {
600 if (target == null) {
601 return null;
602 }
603 Supplier<ActivationFile.Builder> creator = () -> ActivationFile.newBuilder(target);
604 ActivationFile.Builder builder = null;
605 builder = (ActivationFile.Builder) transformActivationFile_Missing(creator, builder, target);
606 builder = (ActivationFile.Builder) transformActivationFile_Exists(creator, builder, target);
607 return builder != null ? builder.build() : target;
608 }
609
610 protected ActivationFile.Builder transformActivationFile_Missing(Supplier<? extends ActivationFile.Builder> creator, ActivationFile.Builder builder, ActivationFile target) {
611 String oldVal = target.getMissing();
612 String newVal = transform(oldVal);
613 return newVal != oldVal ? (builder != null ? builder : creator.get()).missing(newVal) : builder;
614 }
615 protected ActivationFile.Builder transformActivationFile_Exists(Supplier<? extends ActivationFile.Builder> creator, ActivationFile.Builder builder, ActivationFile target) {
616 String oldVal = target.getExists();
617 String newVal = transform(oldVal);
618 return newVal != oldVal ? (builder != null ? builder : creator.get()).exists(newVal) : builder;
619 }
620
621 protected <T> List<T> transform(List<T> list, Function<T, T> transformer) {
622 List<T> newList = list;
623 for (int i = 0; i < list.size(); i++) {
624 T oldVal = list.get(i);
625 T newVal = transformer.apply(oldVal);
626 if (newVal != oldVal) {
627 if (newList == list) {
628 newList = new ArrayList<>(list);
629 }
630 newList.set(i, newVal);
631 }
632 }
633 return newList;
634 }
635
636 protected <T> Map<String, T> transform(Map<String, T> map, Function<T, T> transformer) {
637 Map<String, T> newMap = map;
638 for (String key : map.keySet()) {
639 T oldVal = map.get(key);
640 T newVal = transformer.apply(oldVal);
641 if (newVal != oldVal) {
642 if (newMap == map) {
643 newMap = new HashMap<>(map);
644 }
645 newMap.put(key, newVal);
646 }
647 }
648 return newMap;
649 }
650
651 protected XmlNode transform(XmlNode node) {
652 if (node != null) {
653 String oldValue = node.getValue();
654 String newValue = transform(oldValue);
655 Map<String, String> oldAttrs = node.getAttributes();
656 Map<String, String> newAttrs = transform(oldAttrs, this::transform);
657 List<XmlNode> oldChildren = node.getChildren();
658 List<XmlNode> newChildren = transform(oldChildren, this::transform);
659 if (oldValue != newValue || oldAttrs != newAttrs || oldChildren != newChildren) {
660 return new XmlNodeImpl(node.getPrefix(), node.getNamespaceUri(), node.getName(),
661 newValue, newAttrs, newChildren, node.getInputLocation());
662 }
663 }
664 return node;
665 }
666 }