View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from merger.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.model.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.Objects;
17  import java.util.function.BinaryOperator;
18  import java.util.function.Function;
19  import java.util.stream.Collectors;
20  
21  import org.apache.maven.api.annotations.Generated;
22  import org.apache.maven.api.xml.XmlNode;
23  import org.apache.maven.api.model.Model;
24  import org.apache.maven.api.model.ModelBase;
25  import org.apache.maven.api.model.PluginContainer;
26  import org.apache.maven.api.model.PluginConfiguration;
27  import org.apache.maven.api.model.BuildBase;
28  import org.apache.maven.api.model.Build;
29  import org.apache.maven.api.model.CiManagement;
30  import org.apache.maven.api.model.Notifier;
31  import org.apache.maven.api.model.Contributor;
32  import org.apache.maven.api.model.Dependency;
33  import org.apache.maven.api.model.Developer;
34  import org.apache.maven.api.model.Exclusion;
35  import org.apache.maven.api.model.IssueManagement;
36  import org.apache.maven.api.model.DistributionManagement;
37  import org.apache.maven.api.model.License;
38  import org.apache.maven.api.model.MailingList;
39  import org.apache.maven.api.model.Organization;
40  import org.apache.maven.api.model.PatternSet;
41  import org.apache.maven.api.model.Parent;
42  import org.apache.maven.api.model.Scm;
43  import org.apache.maven.api.model.FileSet;
44  import org.apache.maven.api.model.Resource;
45  import org.apache.maven.api.model.RepositoryBase;
46  import org.apache.maven.api.model.Repository;
47  import org.apache.maven.api.model.DeploymentRepository;
48  import org.apache.maven.api.model.RepositoryPolicy;
49  import org.apache.maven.api.model.Site;
50  import org.apache.maven.api.model.ConfigurationContainer;
51  import org.apache.maven.api.model.Plugin;
52  import org.apache.maven.api.model.PluginExecution;
53  import org.apache.maven.api.model.DependencyManagement;
54  import org.apache.maven.api.model.PluginManagement;
55  import org.apache.maven.api.model.Reporting;
56  import org.apache.maven.api.model.Profile;
57  import org.apache.maven.api.model.Activation;
58  import org.apache.maven.api.model.ActivationProperty;
59  import org.apache.maven.api.model.ActivationOS;
60  import org.apache.maven.api.model.ActivationFile;
61  import org.apache.maven.api.model.ReportPlugin;
62  import org.apache.maven.api.model.ReportSet;
63  import org.apache.maven.api.model.Prerequisites;
64  import org.apache.maven.api.model.Relocation;
65  import org.apache.maven.api.model.Extension;
66  import org.apache.maven.api.model.InputLocation;
67  import org.apache.maven.api.model.InputSource;
68  
69  @Generated
70  public class MavenMerger {
71  
72      private final boolean deepMerge;
73  
74      public MavenMerger() {
75          this(true);
76      }
77  
78      public MavenMerger(boolean deepMerge) {
79          this.deepMerge = deepMerge;
80      }
81  
82      /**
83       * Merges the specified source object into the given target object.
84       *
85       * @param target The target object whose existing contents should be merged with the source, must not be
86       *            <code>null</code>.
87       * @param source The (read-only) source object that should be merged into the target object, may be
88       *            <code>null</code>.
89       * @param sourceDominant A flag indicating whether either the target object or the source object provides the
90       *            dominant data.
91       * @param hints A set of key-value pairs that customized merger implementations can use to carry domain-specific
92       *            information along, may be <code>null</code>.
93       */
94      public Model merge(Model target, Model source, boolean sourceDominant, Map<?, ?> hints) {
95          Objects.requireNonNull(target, "target cannot be null");
96          if (source == null) {
97              return target;
98          }
99          Map<Object, Object> context = new HashMap<>();
100         if (hints != null) {
101             context.putAll(hints);
102         }
103         return mergeModel(target, source, sourceDominant, context);
104     }
105 
106     protected Model mergeModel(Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
107         Model.Builder builder = Model.newBuilder(target);
108         mergeModel(builder, target, source, sourceDominant, context);
109         return builder.build();
110     }
111 
112     protected void mergeModel(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
113         mergeModelBase(builder, target, source, sourceDominant, context);
114         mergeModel_PomFile(builder, target, source, sourceDominant, context);
115         mergeModel_ModelVersion(builder, target, source, sourceDominant, context);
116         mergeModel_Parent(builder, target, source, sourceDominant, context);
117         mergeModel_GroupId(builder, target, source, sourceDominant, context);
118         mergeModel_ArtifactId(builder, target, source, sourceDominant, context);
119         mergeModel_Version(builder, target, source, sourceDominant, context);
120         mergeModel_Packaging(builder, target, source, sourceDominant, context);
121         mergeModel_Name(builder, target, source, sourceDominant, context);
122         mergeModel_Description(builder, target, source, sourceDominant, context);
123         mergeModel_Url(builder, target, source, sourceDominant, context);
124         mergeModel_ChildProjectUrlInheritAppendPath(builder, target, source, sourceDominant, context);
125         mergeModel_Root(builder, target, source, sourceDominant, context);
126         mergeModel_PreserveModelVersion(builder, target, source, sourceDominant, context);
127         mergeModel_InceptionYear(builder, target, source, sourceDominant, context);
128         mergeModel_Organization(builder, target, source, sourceDominant, context);
129         mergeModel_Licenses(builder, target, source, sourceDominant, context);
130         mergeModel_Developers(builder, target, source, sourceDominant, context);
131         mergeModel_Contributors(builder, target, source, sourceDominant, context);
132         mergeModel_MailingLists(builder, target, source, sourceDominant, context);
133         mergeModel_Prerequisites(builder, target, source, sourceDominant, context);
134         mergeModel_Scm(builder, target, source, sourceDominant, context);
135         mergeModel_IssueManagement(builder, target, source, sourceDominant, context);
136         mergeModel_CiManagement(builder, target, source, sourceDominant, context);
137         mergeModel_Build(builder, target, source, sourceDominant, context);
138         mergeModel_Profiles(builder, target, source, sourceDominant, context);
139     }
140 
141     protected void mergeModel_Modules(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
142         builder.modules(merge(target.getModules(), source.getModules(), sourceDominant, e -> e));
143     }
144     protected void mergeModel_DistributionManagement(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
145         DistributionManagement src = source.getDistributionManagement();
146         if (src != null) {
147             DistributionManagement tgt = target.getDistributionManagement();
148             if (tgt == null) {
149                 tgt = DistributionManagement.newInstance(false);
150             }
151             DistributionManagement merged = mergeDistributionManagement(tgt, src, sourceDominant, context);
152             builder.distributionManagement(merged);
153             if (target.getDistributionManagement() == null) {
154                 builder.location("distributionManagement", source.getLocation("distributionManagement"));
155             } else if (merged != tgt) {
156                 builder.location("distributionManagement", new InputLocation(-1, -1));
157             }
158         }
159     }
160     protected void mergeModel_Properties(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
161         Map<String, String> src = source.getProperties();
162         if (!src.isEmpty()) {
163             Map<String, String> tgt = target.getProperties();
164             if (tgt.isEmpty()) {
165                 builder.properties(src);
166                 builder.location("properties", source.getLocation("properties"));
167             } else {
168                 Map<String, String> merged = new HashMap<>();
169                 merged.putAll(sourceDominant ? target.getProperties() : source.getProperties());
170                 merged.putAll(sourceDominant ? source.getProperties() : target.getProperties());
171                 builder.properties(merged);
172                 builder.location("properties", InputLocation.merge(target.getLocation("properties"), source.getLocation("properties"), sourceDominant));
173             }
174         }
175     }
176     protected void mergeModel_DependencyManagement(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
177         DependencyManagement src = source.getDependencyManagement();
178         if (src != null) {
179             DependencyManagement tgt = target.getDependencyManagement();
180             if (tgt == null) {
181                 tgt = DependencyManagement.newInstance(false);
182             }
183             DependencyManagement merged = mergeDependencyManagement(tgt, src, sourceDominant, context);
184             builder.dependencyManagement(merged);
185             if (target.getDependencyManagement() == null) {
186                 builder.location("dependencyManagement", source.getLocation("dependencyManagement"));
187             } else if (merged != tgt) {
188                 builder.location("dependencyManagement", new InputLocation(-1, -1));
189             }
190         }
191     }
192     protected void mergeModel_Dependencies(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
193         if (deepMerge) {
194             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), getDependencyKey(),
195                     (t, s) -> mergeDependency(t, s, sourceDominant, context)));
196         } else {
197             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey()));
198         }
199     }
200     protected void mergeModel_Repositories(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
201         if (deepMerge) {
202             builder.repositories(merge(target.getRepositories(), source.getRepositories(), getRepositoryKey(),
203                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
204         } else {
205             builder.repositories(merge(target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey()));
206         }
207     }
208     protected void mergeModel_PluginRepositories(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
209         if (deepMerge) {
210             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
211                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
212         } else {
213             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey()));
214         }
215     }
216     protected void mergeModel_Reporting(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
217         Reporting src = source.getReporting();
218         if (src != null) {
219             Reporting tgt = target.getReporting();
220             if (tgt == null) {
221                 tgt = Reporting.newInstance(false);
222             }
223             Reporting merged = mergeReporting(tgt, src, sourceDominant, context);
224             builder.reporting(merged);
225             if (target.getReporting() == null) {
226                 builder.location("reporting", source.getLocation("reporting"));
227             } else if (merged != tgt) {
228                 builder.location("reporting", new InputLocation(-1, -1));
229             }
230         }
231     }
232     protected void mergeModel_PomFile(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
233         if (sourceDominant) {
234             builder.pomFile(source.getPomFile());
235         }
236     }
237     protected void mergeModel_ModelVersion(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
238         String src = source.getModelVersion();
239         String tgt = target.getModelVersion();
240         if (src != null && (sourceDominant || tgt == null)) {
241             builder.modelVersion(src);
242             builder.location("modelVersion", source.getLocation("modelVersion"));
243         }
244     }
245     protected void mergeModel_Parent(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
246         Parent src = source.getParent();
247         if (src != null) {
248             Parent tgt = target.getParent();
249             if (tgt == null) {
250                 tgt = Parent.newInstance(false);
251             }
252             Parent merged = mergeParent(tgt, src, sourceDominant, context);
253             builder.parent(merged);
254             if (target.getParent() == null) {
255                 builder.location("parent", source.getLocation("parent"));
256             } else if (merged != tgt) {
257                 builder.location("parent", new InputLocation(-1, -1));
258             }
259         }
260     }
261     protected void mergeModel_GroupId(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
262         String src = source.getGroupId();
263         String tgt = target.getGroupId();
264         if (src != null && (sourceDominant || tgt == null)) {
265             builder.groupId(src);
266             builder.location("groupId", source.getLocation("groupId"));
267         }
268     }
269     protected void mergeModel_ArtifactId(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
270         String src = source.getArtifactId();
271         String tgt = target.getArtifactId();
272         if (src != null && (sourceDominant || tgt == null)) {
273             builder.artifactId(src);
274             builder.location("artifactId", source.getLocation("artifactId"));
275         }
276     }
277     protected void mergeModel_Version(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
278         String src = source.getVersion();
279         String tgt = target.getVersion();
280         if (src != null && (sourceDominant || tgt == null)) {
281             builder.version(src);
282             builder.location("version", source.getLocation("version"));
283         }
284     }
285     protected void mergeModel_Packaging(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
286         String src = source.getPackaging();
287         String tgt = target.getPackaging();
288         if (src != null && (sourceDominant || tgt == null)) {
289             builder.packaging(src);
290             builder.location("packaging", source.getLocation("packaging"));
291         }
292     }
293     protected void mergeModel_Name(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
294         String src = source.getName();
295         String tgt = target.getName();
296         if (src != null && (sourceDominant || tgt == null)) {
297             builder.name(src);
298             builder.location("name", source.getLocation("name"));
299         }
300     }
301     protected void mergeModel_Description(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
302         String src = source.getDescription();
303         String tgt = target.getDescription();
304         if (src != null && (sourceDominant || tgt == null)) {
305             builder.description(src);
306             builder.location("description", source.getLocation("description"));
307         }
308     }
309     protected void mergeModel_Url(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
310         String src = source.getUrl();
311         String tgt = target.getUrl();
312         if (src != null && (sourceDominant || tgt == null)) {
313             builder.url(src);
314             builder.location("url", source.getLocation("url"));
315         }
316     }
317     protected void mergeModel_ChildProjectUrlInheritAppendPath(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
318         String src = source.getChildProjectUrlInheritAppendPath();
319         String tgt = target.getChildProjectUrlInheritAppendPath();
320         if (src != null && (sourceDominant || tgt == null)) {
321             builder.childProjectUrlInheritAppendPath(src);
322             builder.location("childProjectUrlInheritAppendPath", source.getLocation("childProjectUrlInheritAppendPath"));
323         }
324     }
325     protected void mergeModel_Root(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
326         if (sourceDominant) {
327             builder.root(source.isRoot());
328         }
329     }
330     protected void mergeModel_PreserveModelVersion(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
331         if (sourceDominant) {
332             builder.preserveModelVersion(source.isPreserveModelVersion());
333         }
334     }
335     protected void mergeModel_InceptionYear(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
336         String src = source.getInceptionYear();
337         String tgt = target.getInceptionYear();
338         if (src != null && (sourceDominant || tgt == null)) {
339             builder.inceptionYear(src);
340             builder.location("inceptionYear", source.getLocation("inceptionYear"));
341         }
342     }
343     protected void mergeModel_Organization(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
344         Organization src = source.getOrganization();
345         if (src != null) {
346             Organization tgt = target.getOrganization();
347             if (tgt == null) {
348                 tgt = Organization.newInstance(false);
349             }
350             Organization merged = mergeOrganization(tgt, src, sourceDominant, context);
351             builder.organization(merged);
352             if (target.getOrganization() == null) {
353                 builder.location("organization", source.getLocation("organization"));
354             } else if (merged != tgt) {
355                 builder.location("organization", new InputLocation(-1, -1));
356             }
357         }
358     }
359     protected void mergeModel_Licenses(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
360         if (deepMerge) {
361             builder.licenses(merge(target.getLicenses(), source.getLicenses(), getLicenseKey(),
362                     (t, s) -> mergeLicense(t, s, sourceDominant, context)));
363         } else {
364             builder.licenses(merge(target.getLicenses(), source.getLicenses(), sourceDominant, getLicenseKey()));
365         }
366     }
367     protected void mergeModel_Developers(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
368         if (deepMerge) {
369             builder.developers(merge(target.getDevelopers(), source.getDevelopers(), getDeveloperKey(),
370                     (t, s) -> mergeDeveloper(t, s, sourceDominant, context)));
371         } else {
372             builder.developers(merge(target.getDevelopers(), source.getDevelopers(), sourceDominant, getDeveloperKey()));
373         }
374     }
375     protected void mergeModel_Contributors(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
376         if (deepMerge) {
377             builder.contributors(merge(target.getContributors(), source.getContributors(), getContributorKey(),
378                     (t, s) -> mergeContributor(t, s, sourceDominant, context)));
379         } else {
380             builder.contributors(merge(target.getContributors(), source.getContributors(), sourceDominant, getContributorKey()));
381         }
382     }
383     protected void mergeModel_MailingLists(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
384         if (deepMerge) {
385             builder.mailingLists(merge(target.getMailingLists(), source.getMailingLists(), getMailingListKey(),
386                     (t, s) -> mergeMailingList(t, s, sourceDominant, context)));
387         } else {
388             builder.mailingLists(merge(target.getMailingLists(), source.getMailingLists(), sourceDominant, getMailingListKey()));
389         }
390     }
391     protected void mergeModel_Prerequisites(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
392         Prerequisites src = source.getPrerequisites();
393         if (src != null) {
394             Prerequisites tgt = target.getPrerequisites();
395             if (tgt == null) {
396                 tgt = Prerequisites.newInstance(false);
397             }
398             Prerequisites merged = mergePrerequisites(tgt, src, sourceDominant, context);
399             builder.prerequisites(merged);
400             if (target.getPrerequisites() == null) {
401                 builder.location("prerequisites", source.getLocation("prerequisites"));
402             } else if (merged != tgt) {
403                 builder.location("prerequisites", new InputLocation(-1, -1));
404             }
405         }
406     }
407     protected void mergeModel_Scm(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
408         Scm src = source.getScm();
409         if (src != null) {
410             Scm tgt = target.getScm();
411             if (tgt == null) {
412                 tgt = Scm.newInstance(false);
413             }
414             Scm merged = mergeScm(tgt, src, sourceDominant, context);
415             builder.scm(merged);
416             if (target.getScm() == null) {
417                 builder.location("scm", source.getLocation("scm"));
418             } else if (merged != tgt) {
419                 builder.location("scm", new InputLocation(-1, -1));
420             }
421         }
422     }
423     protected void mergeModel_IssueManagement(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
424         IssueManagement src = source.getIssueManagement();
425         if (src != null) {
426             IssueManagement tgt = target.getIssueManagement();
427             if (tgt == null) {
428                 tgt = IssueManagement.newInstance(false);
429             }
430             IssueManagement merged = mergeIssueManagement(tgt, src, sourceDominant, context);
431             builder.issueManagement(merged);
432             if (target.getIssueManagement() == null) {
433                 builder.location("issueManagement", source.getLocation("issueManagement"));
434             } else if (merged != tgt) {
435                 builder.location("issueManagement", new InputLocation(-1, -1));
436             }
437         }
438     }
439     protected void mergeModel_CiManagement(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
440         CiManagement src = source.getCiManagement();
441         if (src != null) {
442             CiManagement tgt = target.getCiManagement();
443             if (tgt == null) {
444                 tgt = CiManagement.newInstance(false);
445             }
446             CiManagement merged = mergeCiManagement(tgt, src, sourceDominant, context);
447             builder.ciManagement(merged);
448             if (target.getCiManagement() == null) {
449                 builder.location("ciManagement", source.getLocation("ciManagement"));
450             } else if (merged != tgt) {
451                 builder.location("ciManagement", new InputLocation(-1, -1));
452             }
453         }
454     }
455     protected void mergeModel_Build(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
456         Build src = source.getBuild();
457         if (src != null) {
458             Build tgt = target.getBuild();
459             if (tgt == null) {
460                 tgt = Build.newInstance(false);
461             }
462             Build merged = mergeBuild(tgt, src, sourceDominant, context);
463             builder.build(merged);
464             if (target.getBuild() == null) {
465                 builder.location("build", source.getLocation("build"));
466             } else if (merged != tgt) {
467                 builder.location("build", new InputLocation(-1, -1));
468             }
469         }
470     }
471     protected void mergeModel_Profiles(Model.Builder builder, Model target, Model source, boolean sourceDominant, Map<Object, Object> context) {
472         if (deepMerge) {
473             builder.profiles(merge(target.getProfiles(), source.getProfiles(), getProfileKey(),
474                     (t, s) -> mergeProfile(t, s, sourceDominant, context)));
475         } else {
476             builder.profiles(merge(target.getProfiles(), source.getProfiles(), sourceDominant, getProfileKey()));
477         }
478     }
479 
480     protected ModelBase mergeModelBase(ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
481         ModelBase.Builder builder = ModelBase.newBuilder(target);
482         mergeModelBase(builder, target, source, sourceDominant, context);
483         return builder.build();
484     }
485 
486     protected void mergeModelBase(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
487         mergeModelBase_Modules(builder, target, source, sourceDominant, context);
488         mergeModelBase_DistributionManagement(builder, target, source, sourceDominant, context);
489         mergeModelBase_Properties(builder, target, source, sourceDominant, context);
490         mergeModelBase_DependencyManagement(builder, target, source, sourceDominant, context);
491         mergeModelBase_Dependencies(builder, target, source, sourceDominant, context);
492         mergeModelBase_Repositories(builder, target, source, sourceDominant, context);
493         mergeModelBase_PluginRepositories(builder, target, source, sourceDominant, context);
494         mergeModelBase_Reporting(builder, target, source, sourceDominant, context);
495     }
496 
497     protected void mergeModelBase_Modules(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
498         builder.modules(merge(target.getModules(), source.getModules(), sourceDominant, e -> e));
499     }
500     protected void mergeModelBase_DistributionManagement(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
501         DistributionManagement src = source.getDistributionManagement();
502         if (src != null) {
503             DistributionManagement tgt = target.getDistributionManagement();
504             if (tgt == null) {
505                 tgt = DistributionManagement.newInstance(false);
506             }
507             DistributionManagement merged = mergeDistributionManagement(tgt, src, sourceDominant, context);
508             builder.distributionManagement(merged);
509             if (target.getDistributionManagement() == null) {
510                 builder.location("distributionManagement", source.getLocation("distributionManagement"));
511             } else if (merged != tgt) {
512                 builder.location("distributionManagement", new InputLocation(-1, -1));
513             }
514         }
515     }
516     protected void mergeModelBase_Properties(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
517         Map<String, String> src = source.getProperties();
518         if (!src.isEmpty()) {
519             Map<String, String> tgt = target.getProperties();
520             if (tgt.isEmpty()) {
521                 builder.properties(src);
522                 builder.location("properties", source.getLocation("properties"));
523             } else {
524                 Map<String, String> merged = new HashMap<>();
525                 merged.putAll(sourceDominant ? target.getProperties() : source.getProperties());
526                 merged.putAll(sourceDominant ? source.getProperties() : target.getProperties());
527                 builder.properties(merged);
528                 builder.location("properties", InputLocation.merge(target.getLocation("properties"), source.getLocation("properties"), sourceDominant));
529             }
530         }
531     }
532     protected void mergeModelBase_DependencyManagement(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
533         DependencyManagement src = source.getDependencyManagement();
534         if (src != null) {
535             DependencyManagement tgt = target.getDependencyManagement();
536             if (tgt == null) {
537                 tgt = DependencyManagement.newInstance(false);
538             }
539             DependencyManagement merged = mergeDependencyManagement(tgt, src, sourceDominant, context);
540             builder.dependencyManagement(merged);
541             if (target.getDependencyManagement() == null) {
542                 builder.location("dependencyManagement", source.getLocation("dependencyManagement"));
543             } else if (merged != tgt) {
544                 builder.location("dependencyManagement", new InputLocation(-1, -1));
545             }
546         }
547     }
548     protected void mergeModelBase_Dependencies(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
549         if (deepMerge) {
550             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), getDependencyKey(),
551                     (t, s) -> mergeDependency(t, s, sourceDominant, context)));
552         } else {
553             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey()));
554         }
555     }
556     protected void mergeModelBase_Repositories(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
557         if (deepMerge) {
558             builder.repositories(merge(target.getRepositories(), source.getRepositories(), getRepositoryKey(),
559                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
560         } else {
561             builder.repositories(merge(target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey()));
562         }
563     }
564     protected void mergeModelBase_PluginRepositories(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
565         if (deepMerge) {
566             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
567                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
568         } else {
569             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey()));
570         }
571     }
572     protected void mergeModelBase_Reporting(ModelBase.Builder builder, ModelBase target, ModelBase source, boolean sourceDominant, Map<Object, Object> context) {
573         Reporting src = source.getReporting();
574         if (src != null) {
575             Reporting tgt = target.getReporting();
576             if (tgt == null) {
577                 tgt = Reporting.newInstance(false);
578             }
579             Reporting merged = mergeReporting(tgt, src, sourceDominant, context);
580             builder.reporting(merged);
581             if (target.getReporting() == null) {
582                 builder.location("reporting", source.getLocation("reporting"));
583             } else if (merged != tgt) {
584                 builder.location("reporting", new InputLocation(-1, -1));
585             }
586         }
587     }
588 
589     protected PluginContainer mergePluginContainer(PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context) {
590         PluginContainer.Builder builder = PluginContainer.newBuilder(target);
591         mergePluginContainer(builder, target, source, sourceDominant, context);
592         return builder.build();
593     }
594 
595     protected void mergePluginContainer(PluginContainer.Builder builder, PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context) {
596         mergePluginContainer_Plugins(builder, target, source, sourceDominant, context);
597     }
598 
599     protected void mergePluginContainer_Plugins(PluginContainer.Builder builder, PluginContainer target, PluginContainer source, boolean sourceDominant, Map<Object, Object> context) {
600         if (deepMerge) {
601             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getPluginKey(),
602                     (t, s) -> mergePlugin(t, s, sourceDominant, context)));
603         } else {
604             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey()));
605         }
606     }
607 
608     protected PluginConfiguration mergePluginConfiguration(PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context) {
609         PluginConfiguration.Builder builder = PluginConfiguration.newBuilder(target);
610         mergePluginConfiguration(builder, target, source, sourceDominant, context);
611         return builder.build();
612     }
613 
614     protected void mergePluginConfiguration(PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context) {
615         mergePluginContainer(builder, target, source, sourceDominant, context);
616         mergePluginConfiguration_PluginManagement(builder, target, source, sourceDominant, context);
617     }
618 
619     protected void mergePluginConfiguration_Plugins(PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context) {
620         if (deepMerge) {
621             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getPluginKey(),
622                     (t, s) -> mergePlugin(t, s, sourceDominant, context)));
623         } else {
624             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey()));
625         }
626     }
627     protected void mergePluginConfiguration_PluginManagement(PluginConfiguration.Builder builder, PluginConfiguration target, PluginConfiguration source, boolean sourceDominant, Map<Object, Object> context) {
628         PluginManagement src = source.getPluginManagement();
629         if (src != null) {
630             PluginManagement tgt = target.getPluginManagement();
631             if (tgt == null) {
632                 tgt = PluginManagement.newInstance(false);
633             }
634             PluginManagement merged = mergePluginManagement(tgt, src, sourceDominant, context);
635             builder.pluginManagement(merged);
636             if (target.getPluginManagement() == null) {
637                 builder.location("pluginManagement", source.getLocation("pluginManagement"));
638             } else if (merged != tgt) {
639                 builder.location("pluginManagement", new InputLocation(-1, -1));
640             }
641         }
642     }
643 
644     protected BuildBase mergeBuildBase(BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
645         BuildBase.Builder builder = BuildBase.newBuilder(target);
646         mergeBuildBase(builder, target, source, sourceDominant, context);
647         return builder.build();
648     }
649 
650     protected void mergeBuildBase(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
651         mergePluginConfiguration(builder, target, source, sourceDominant, context);
652         mergeBuildBase_DefaultGoal(builder, target, source, sourceDominant, context);
653         mergeBuildBase_Resources(builder, target, source, sourceDominant, context);
654         mergeBuildBase_TestResources(builder, target, source, sourceDominant, context);
655         mergeBuildBase_Directory(builder, target, source, sourceDominant, context);
656         mergeBuildBase_FinalName(builder, target, source, sourceDominant, context);
657         mergeBuildBase_Filters(builder, target, source, sourceDominant, context);
658     }
659 
660     protected void mergeBuildBase_Plugins(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
661         if (deepMerge) {
662             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getPluginKey(),
663                     (t, s) -> mergePlugin(t, s, sourceDominant, context)));
664         } else {
665             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey()));
666         }
667     }
668     protected void mergeBuildBase_PluginManagement(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
669         PluginManagement src = source.getPluginManagement();
670         if (src != null) {
671             PluginManagement tgt = target.getPluginManagement();
672             if (tgt == null) {
673                 tgt = PluginManagement.newInstance(false);
674             }
675             PluginManagement merged = mergePluginManagement(tgt, src, sourceDominant, context);
676             builder.pluginManagement(merged);
677             if (target.getPluginManagement() == null) {
678                 builder.location("pluginManagement", source.getLocation("pluginManagement"));
679             } else if (merged != tgt) {
680                 builder.location("pluginManagement", new InputLocation(-1, -1));
681             }
682         }
683     }
684     protected void mergeBuildBase_DefaultGoal(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
685         String src = source.getDefaultGoal();
686         String tgt = target.getDefaultGoal();
687         if (src != null && (sourceDominant || tgt == null)) {
688             builder.defaultGoal(src);
689             builder.location("defaultGoal", source.getLocation("defaultGoal"));
690         }
691     }
692     protected void mergeBuildBase_Resources(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
693         if (deepMerge) {
694             builder.resources(merge(target.getResources(), source.getResources(), getResourceKey(),
695                     (t, s) -> mergeResource(t, s, sourceDominant, context)));
696         } else {
697             builder.resources(merge(target.getResources(), source.getResources(), sourceDominant, getResourceKey()));
698         }
699     }
700     protected void mergeBuildBase_TestResources(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
701         if (deepMerge) {
702             builder.testResources(merge(target.getTestResources(), source.getTestResources(), getResourceKey(),
703                     (t, s) -> mergeResource(t, s, sourceDominant, context)));
704         } else {
705             builder.testResources(merge(target.getTestResources(), source.getTestResources(), sourceDominant, getResourceKey()));
706         }
707     }
708     protected void mergeBuildBase_Directory(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
709         String src = source.getDirectory();
710         String tgt = target.getDirectory();
711         if (src != null && (sourceDominant || tgt == null)) {
712             builder.directory(src);
713             builder.location("directory", source.getLocation("directory"));
714         }
715     }
716     protected void mergeBuildBase_FinalName(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
717         String src = source.getFinalName();
718         String tgt = target.getFinalName();
719         if (src != null && (sourceDominant || tgt == null)) {
720             builder.finalName(src);
721             builder.location("finalName", source.getLocation("finalName"));
722         }
723     }
724     protected void mergeBuildBase_Filters(BuildBase.Builder builder, BuildBase target, BuildBase source, boolean sourceDominant, Map<Object, Object> context) {
725         builder.filters(merge(target.getFilters(), source.getFilters(), sourceDominant, e -> e));
726     }
727 
728     protected Build mergeBuild(Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
729         Build.Builder builder = Build.newBuilder(target);
730         mergeBuild(builder, target, source, sourceDominant, context);
731         return builder.build();
732     }
733 
734     protected void mergeBuild(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
735         mergeBuildBase(builder, target, source, sourceDominant, context);
736         mergeBuild_SourceDirectory(builder, target, source, sourceDominant, context);
737         mergeBuild_ScriptSourceDirectory(builder, target, source, sourceDominant, context);
738         mergeBuild_TestSourceDirectory(builder, target, source, sourceDominant, context);
739         mergeBuild_OutputDirectory(builder, target, source, sourceDominant, context);
740         mergeBuild_TestOutputDirectory(builder, target, source, sourceDominant, context);
741         mergeBuild_Extensions(builder, target, source, sourceDominant, context);
742     }
743 
744     protected void mergeBuild_Plugins(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
745         if (deepMerge) {
746             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getPluginKey(),
747                     (t, s) -> mergePlugin(t, s, sourceDominant, context)));
748         } else {
749             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey()));
750         }
751     }
752     protected void mergeBuild_PluginManagement(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
753         PluginManagement src = source.getPluginManagement();
754         if (src != null) {
755             PluginManagement tgt = target.getPluginManagement();
756             if (tgt == null) {
757                 tgt = PluginManagement.newInstance(false);
758             }
759             PluginManagement merged = mergePluginManagement(tgt, src, sourceDominant, context);
760             builder.pluginManagement(merged);
761             if (target.getPluginManagement() == null) {
762                 builder.location("pluginManagement", source.getLocation("pluginManagement"));
763             } else if (merged != tgt) {
764                 builder.location("pluginManagement", new InputLocation(-1, -1));
765             }
766         }
767     }
768     protected void mergeBuild_DefaultGoal(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
769         String src = source.getDefaultGoal();
770         String tgt = target.getDefaultGoal();
771         if (src != null && (sourceDominant || tgt == null)) {
772             builder.defaultGoal(src);
773             builder.location("defaultGoal", source.getLocation("defaultGoal"));
774         }
775     }
776     protected void mergeBuild_Resources(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
777         if (deepMerge) {
778             builder.resources(merge(target.getResources(), source.getResources(), getResourceKey(),
779                     (t, s) -> mergeResource(t, s, sourceDominant, context)));
780         } else {
781             builder.resources(merge(target.getResources(), source.getResources(), sourceDominant, getResourceKey()));
782         }
783     }
784     protected void mergeBuild_TestResources(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
785         if (deepMerge) {
786             builder.testResources(merge(target.getTestResources(), source.getTestResources(), getResourceKey(),
787                     (t, s) -> mergeResource(t, s, sourceDominant, context)));
788         } else {
789             builder.testResources(merge(target.getTestResources(), source.getTestResources(), sourceDominant, getResourceKey()));
790         }
791     }
792     protected void mergeBuild_Directory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
793         String src = source.getDirectory();
794         String tgt = target.getDirectory();
795         if (src != null && (sourceDominant || tgt == null)) {
796             builder.directory(src);
797             builder.location("directory", source.getLocation("directory"));
798         }
799     }
800     protected void mergeBuild_FinalName(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
801         String src = source.getFinalName();
802         String tgt = target.getFinalName();
803         if (src != null && (sourceDominant || tgt == null)) {
804             builder.finalName(src);
805             builder.location("finalName", source.getLocation("finalName"));
806         }
807     }
808     protected void mergeBuild_Filters(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
809         builder.filters(merge(target.getFilters(), source.getFilters(), sourceDominant, e -> e));
810     }
811     protected void mergeBuild_SourceDirectory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
812         String src = source.getSourceDirectory();
813         String tgt = target.getSourceDirectory();
814         if (src != null && (sourceDominant || tgt == null)) {
815             builder.sourceDirectory(src);
816             builder.location("sourceDirectory", source.getLocation("sourceDirectory"));
817         }
818     }
819     protected void mergeBuild_ScriptSourceDirectory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
820         String src = source.getScriptSourceDirectory();
821         String tgt = target.getScriptSourceDirectory();
822         if (src != null && (sourceDominant || tgt == null)) {
823             builder.scriptSourceDirectory(src);
824             builder.location("scriptSourceDirectory", source.getLocation("scriptSourceDirectory"));
825         }
826     }
827     protected void mergeBuild_TestSourceDirectory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
828         String src = source.getTestSourceDirectory();
829         String tgt = target.getTestSourceDirectory();
830         if (src != null && (sourceDominant || tgt == null)) {
831             builder.testSourceDirectory(src);
832             builder.location("testSourceDirectory", source.getLocation("testSourceDirectory"));
833         }
834     }
835     protected void mergeBuild_OutputDirectory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
836         String src = source.getOutputDirectory();
837         String tgt = target.getOutputDirectory();
838         if (src != null && (sourceDominant || tgt == null)) {
839             builder.outputDirectory(src);
840             builder.location("outputDirectory", source.getLocation("outputDirectory"));
841         }
842     }
843     protected void mergeBuild_TestOutputDirectory(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
844         String src = source.getTestOutputDirectory();
845         String tgt = target.getTestOutputDirectory();
846         if (src != null && (sourceDominant || tgt == null)) {
847             builder.testOutputDirectory(src);
848             builder.location("testOutputDirectory", source.getLocation("testOutputDirectory"));
849         }
850     }
851     protected void mergeBuild_Extensions(Build.Builder builder, Build target, Build source, boolean sourceDominant, Map<Object, Object> context) {
852         if (deepMerge) {
853             builder.extensions(merge(target.getExtensions(), source.getExtensions(), getExtensionKey(),
854                     (t, s) -> mergeExtension(t, s, sourceDominant, context)));
855         } else {
856             builder.extensions(merge(target.getExtensions(), source.getExtensions(), sourceDominant, getExtensionKey()));
857         }
858     }
859 
860     protected CiManagement mergeCiManagement(CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context) {
861         CiManagement.Builder builder = CiManagement.newBuilder(target);
862         mergeCiManagement(builder, target, source, sourceDominant, context);
863         return builder.build();
864     }
865 
866     protected void mergeCiManagement(CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context) {
867         mergeCiManagement_System(builder, target, source, sourceDominant, context);
868         mergeCiManagement_Url(builder, target, source, sourceDominant, context);
869         mergeCiManagement_Notifiers(builder, target, source, sourceDominant, context);
870     }
871 
872     protected void mergeCiManagement_System(CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context) {
873         String src = source.getSystem();
874         String tgt = target.getSystem();
875         if (src != null && (sourceDominant || tgt == null)) {
876             builder.system(src);
877             builder.location("system", source.getLocation("system"));
878         }
879     }
880     protected void mergeCiManagement_Url(CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context) {
881         String src = source.getUrl();
882         String tgt = target.getUrl();
883         if (src != null && (sourceDominant || tgt == null)) {
884             builder.url(src);
885             builder.location("url", source.getLocation("url"));
886         }
887     }
888     protected void mergeCiManagement_Notifiers(CiManagement.Builder builder, CiManagement target, CiManagement source, boolean sourceDominant, Map<Object, Object> context) {
889         if (deepMerge) {
890             builder.notifiers(merge(target.getNotifiers(), source.getNotifiers(), getNotifierKey(),
891                     (t, s) -> mergeNotifier(t, s, sourceDominant, context)));
892         } else {
893             builder.notifiers(merge(target.getNotifiers(), source.getNotifiers(), sourceDominant, getNotifierKey()));
894         }
895     }
896 
897     protected Notifier mergeNotifier(Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
898         Notifier.Builder builder = Notifier.newBuilder(target);
899         mergeNotifier(builder, target, source, sourceDominant, context);
900         return builder.build();
901     }
902 
903     protected void mergeNotifier(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
904         mergeNotifier_Type(builder, target, source, sourceDominant, context);
905         mergeNotifier_SendOnError(builder, target, source, sourceDominant, context);
906         mergeNotifier_SendOnFailure(builder, target, source, sourceDominant, context);
907         mergeNotifier_SendOnSuccess(builder, target, source, sourceDominant, context);
908         mergeNotifier_SendOnWarning(builder, target, source, sourceDominant, context);
909         mergeNotifier_Address(builder, target, source, sourceDominant, context);
910         mergeNotifier_Configuration(builder, target, source, sourceDominant, context);
911     }
912 
913     protected void mergeNotifier_Type(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
914         String src = source.getType();
915         String tgt = target.getType();
916         if (src != null && (sourceDominant || tgt == null)) {
917             builder.type(src);
918             builder.location("type", source.getLocation("type"));
919         }
920     }
921     protected void mergeNotifier_SendOnError(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
922         if (sourceDominant) {
923             builder.sendOnError(source.isSendOnError());
924         }
925     }
926     protected void mergeNotifier_SendOnFailure(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
927         if (sourceDominant) {
928             builder.sendOnFailure(source.isSendOnFailure());
929         }
930     }
931     protected void mergeNotifier_SendOnSuccess(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
932         if (sourceDominant) {
933             builder.sendOnSuccess(source.isSendOnSuccess());
934         }
935     }
936     protected void mergeNotifier_SendOnWarning(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
937         if (sourceDominant) {
938             builder.sendOnWarning(source.isSendOnWarning());
939         }
940     }
941     protected void mergeNotifier_Address(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
942         String src = source.getAddress();
943         String tgt = target.getAddress();
944         if (src != null && (sourceDominant || tgt == null)) {
945             builder.address(src);
946             builder.location("address", source.getLocation("address"));
947         }
948     }
949     protected void mergeNotifier_Configuration(Notifier.Builder builder, Notifier target, Notifier source, boolean sourceDominant, Map<Object, Object> context) {
950         Map<String, String> src = source.getConfiguration();
951         if (!src.isEmpty()) {
952             Map<String, String> tgt = target.getConfiguration();
953             if (tgt.isEmpty()) {
954                 builder.configuration(src);
955                 builder.location("configuration", source.getLocation("configuration"));
956             } else {
957                 Map<String, String> merged = new HashMap<>();
958                 merged.putAll(sourceDominant ? target.getConfiguration() : source.getConfiguration());
959                 merged.putAll(sourceDominant ? source.getConfiguration() : target.getConfiguration());
960                 builder.configuration(merged);
961                 builder.location("configuration", InputLocation.merge(target.getLocation("configuration"), source.getLocation("configuration"), sourceDominant));
962             }
963         }
964     }
965 
966     protected Contributor mergeContributor(Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
967         Contributor.Builder builder = Contributor.newBuilder(target);
968         mergeContributor(builder, target, source, sourceDominant, context);
969         return builder.build();
970     }
971 
972     protected void mergeContributor(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
973         mergeContributor_Name(builder, target, source, sourceDominant, context);
974         mergeContributor_Email(builder, target, source, sourceDominant, context);
975         mergeContributor_Url(builder, target, source, sourceDominant, context);
976         mergeContributor_Organization(builder, target, source, sourceDominant, context);
977         mergeContributor_OrganizationUrl(builder, target, source, sourceDominant, context);
978         mergeContributor_Roles(builder, target, source, sourceDominant, context);
979         mergeContributor_Timezone(builder, target, source, sourceDominant, context);
980         mergeContributor_Properties(builder, target, source, sourceDominant, context);
981     }
982 
983     protected void mergeContributor_Name(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
984         String src = source.getName();
985         String tgt = target.getName();
986         if (src != null && (sourceDominant || tgt == null)) {
987             builder.name(src);
988             builder.location("name", source.getLocation("name"));
989         }
990     }
991     protected void mergeContributor_Email(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
992         String src = source.getEmail();
993         String tgt = target.getEmail();
994         if (src != null && (sourceDominant || tgt == null)) {
995             builder.email(src);
996             builder.location("email", source.getLocation("email"));
997         }
998     }
999     protected void mergeContributor_Url(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1000         String src = source.getUrl();
1001         String tgt = target.getUrl();
1002         if (src != null && (sourceDominant || tgt == null)) {
1003             builder.url(src);
1004             builder.location("url", source.getLocation("url"));
1005         }
1006     }
1007     protected void mergeContributor_Organization(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1008         String src = source.getOrganization();
1009         String tgt = target.getOrganization();
1010         if (src != null && (sourceDominant || tgt == null)) {
1011             builder.organization(src);
1012             builder.location("organization", source.getLocation("organization"));
1013         }
1014     }
1015     protected void mergeContributor_OrganizationUrl(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1016         String src = source.getOrganizationUrl();
1017         String tgt = target.getOrganizationUrl();
1018         if (src != null && (sourceDominant || tgt == null)) {
1019             builder.organizationUrl(src);
1020             builder.location("organizationUrl", source.getLocation("organizationUrl"));
1021         }
1022     }
1023     protected void mergeContributor_Roles(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1024         builder.roles(merge(target.getRoles(), source.getRoles(), sourceDominant, e -> e));
1025     }
1026     protected void mergeContributor_Timezone(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1027         String src = source.getTimezone();
1028         String tgt = target.getTimezone();
1029         if (src != null && (sourceDominant || tgt == null)) {
1030             builder.timezone(src);
1031             builder.location("timezone", source.getLocation("timezone"));
1032         }
1033     }
1034     protected void mergeContributor_Properties(Contributor.Builder builder, Contributor target, Contributor source, boolean sourceDominant, Map<Object, Object> context) {
1035         Map<String, String> src = source.getProperties();
1036         if (!src.isEmpty()) {
1037             Map<String, String> tgt = target.getProperties();
1038             if (tgt.isEmpty()) {
1039                 builder.properties(src);
1040                 builder.location("properties", source.getLocation("properties"));
1041             } else {
1042                 Map<String, String> merged = new HashMap<>();
1043                 merged.putAll(sourceDominant ? target.getProperties() : source.getProperties());
1044                 merged.putAll(sourceDominant ? source.getProperties() : target.getProperties());
1045                 builder.properties(merged);
1046                 builder.location("properties", InputLocation.merge(target.getLocation("properties"), source.getLocation("properties"), sourceDominant));
1047             }
1048         }
1049     }
1050 
1051     protected Dependency mergeDependency(Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1052         Dependency.Builder builder = Dependency.newBuilder(target);
1053         mergeDependency(builder, target, source, sourceDominant, context);
1054         return builder.build();
1055     }
1056 
1057     protected void mergeDependency(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1058         mergeDependency_GroupId(builder, target, source, sourceDominant, context);
1059         mergeDependency_ArtifactId(builder, target, source, sourceDominant, context);
1060         mergeDependency_Version(builder, target, source, sourceDominant, context);
1061         mergeDependency_Type(builder, target, source, sourceDominant, context);
1062         mergeDependency_Classifier(builder, target, source, sourceDominant, context);
1063         mergeDependency_Scope(builder, target, source, sourceDominant, context);
1064         mergeDependency_SystemPath(builder, target, source, sourceDominant, context);
1065         mergeDependency_Exclusions(builder, target, source, sourceDominant, context);
1066         mergeDependency_Optional(builder, target, source, sourceDominant, context);
1067     }
1068 
1069     protected void mergeDependency_GroupId(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1070         String src = source.getGroupId();
1071         String tgt = target.getGroupId();
1072         if (src != null && (sourceDominant || tgt == null)) {
1073             builder.groupId(src);
1074             builder.location("groupId", source.getLocation("groupId"));
1075         }
1076     }
1077     protected void mergeDependency_ArtifactId(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1078         String src = source.getArtifactId();
1079         String tgt = target.getArtifactId();
1080         if (src != null && (sourceDominant || tgt == null)) {
1081             builder.artifactId(src);
1082             builder.location("artifactId", source.getLocation("artifactId"));
1083         }
1084     }
1085     protected void mergeDependency_Version(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1086         String src = source.getVersion();
1087         String tgt = target.getVersion();
1088         if (src != null && (sourceDominant || tgt == null)) {
1089             builder.version(src);
1090             builder.location("version", source.getLocation("version"));
1091         }
1092     }
1093     protected void mergeDependency_Type(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1094         String src = source.getType();
1095         String tgt = target.getType();
1096         if (src != null && (sourceDominant || tgt == null)) {
1097             builder.type(src);
1098             builder.location("type", source.getLocation("type"));
1099         }
1100     }
1101     protected void mergeDependency_Classifier(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1102         String src = source.getClassifier();
1103         String tgt = target.getClassifier();
1104         if (src != null && (sourceDominant || tgt == null)) {
1105             builder.classifier(src);
1106             builder.location("classifier", source.getLocation("classifier"));
1107         }
1108     }
1109     protected void mergeDependency_Scope(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1110         String src = source.getScope();
1111         String tgt = target.getScope();
1112         if (src != null && (sourceDominant || tgt == null)) {
1113             builder.scope(src);
1114             builder.location("scope", source.getLocation("scope"));
1115         }
1116     }
1117     protected void mergeDependency_SystemPath(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1118         String src = source.getSystemPath();
1119         String tgt = target.getSystemPath();
1120         if (src != null && (sourceDominant || tgt == null)) {
1121             builder.systemPath(src);
1122             builder.location("systemPath", source.getLocation("systemPath"));
1123         }
1124     }
1125     protected void mergeDependency_Exclusions(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1126         if (deepMerge) {
1127             builder.exclusions(merge(target.getExclusions(), source.getExclusions(), getExclusionKey(),
1128                     (t, s) -> mergeExclusion(t, s, sourceDominant, context)));
1129         } else {
1130             builder.exclusions(merge(target.getExclusions(), source.getExclusions(), sourceDominant, getExclusionKey()));
1131         }
1132     }
1133     protected void mergeDependency_Optional(Dependency.Builder builder, Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context) {
1134         String src = source.getOptional();
1135         String tgt = target.getOptional();
1136         if (src != null && (sourceDominant || tgt == null)) {
1137             builder.optional(src);
1138             builder.location("optional", source.getLocation("optional"));
1139         }
1140     }
1141 
1142     protected Developer mergeDeveloper(Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1143         Developer.Builder builder = Developer.newBuilder(target);
1144         mergeDeveloper(builder, target, source, sourceDominant, context);
1145         return builder.build();
1146     }
1147 
1148     protected void mergeDeveloper(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1149         mergeContributor(builder, target, source, sourceDominant, context);
1150         mergeDeveloper_Id(builder, target, source, sourceDominant, context);
1151     }
1152 
1153     protected void mergeDeveloper_Name(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1154         String src = source.getName();
1155         String tgt = target.getName();
1156         if (src != null && (sourceDominant || tgt == null)) {
1157             builder.name(src);
1158             builder.location("name", source.getLocation("name"));
1159         }
1160     }
1161     protected void mergeDeveloper_Email(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1162         String src = source.getEmail();
1163         String tgt = target.getEmail();
1164         if (src != null && (sourceDominant || tgt == null)) {
1165             builder.email(src);
1166             builder.location("email", source.getLocation("email"));
1167         }
1168     }
1169     protected void mergeDeveloper_Url(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1170         String src = source.getUrl();
1171         String tgt = target.getUrl();
1172         if (src != null && (sourceDominant || tgt == null)) {
1173             builder.url(src);
1174             builder.location("url", source.getLocation("url"));
1175         }
1176     }
1177     protected void mergeDeveloper_Organization(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1178         String src = source.getOrganization();
1179         String tgt = target.getOrganization();
1180         if (src != null && (sourceDominant || tgt == null)) {
1181             builder.organization(src);
1182             builder.location("organization", source.getLocation("organization"));
1183         }
1184     }
1185     protected void mergeDeveloper_OrganizationUrl(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1186         String src = source.getOrganizationUrl();
1187         String tgt = target.getOrganizationUrl();
1188         if (src != null && (sourceDominant || tgt == null)) {
1189             builder.organizationUrl(src);
1190             builder.location("organizationUrl", source.getLocation("organizationUrl"));
1191         }
1192     }
1193     protected void mergeDeveloper_Roles(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1194         builder.roles(merge(target.getRoles(), source.getRoles(), sourceDominant, e -> e));
1195     }
1196     protected void mergeDeveloper_Timezone(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1197         String src = source.getTimezone();
1198         String tgt = target.getTimezone();
1199         if (src != null && (sourceDominant || tgt == null)) {
1200             builder.timezone(src);
1201             builder.location("timezone", source.getLocation("timezone"));
1202         }
1203     }
1204     protected void mergeDeveloper_Properties(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1205         Map<String, String> src = source.getProperties();
1206         if (!src.isEmpty()) {
1207             Map<String, String> tgt = target.getProperties();
1208             if (tgt.isEmpty()) {
1209                 builder.properties(src);
1210                 builder.location("properties", source.getLocation("properties"));
1211             } else {
1212                 Map<String, String> merged = new HashMap<>();
1213                 merged.putAll(sourceDominant ? target.getProperties() : source.getProperties());
1214                 merged.putAll(sourceDominant ? source.getProperties() : target.getProperties());
1215                 builder.properties(merged);
1216                 builder.location("properties", InputLocation.merge(target.getLocation("properties"), source.getLocation("properties"), sourceDominant));
1217             }
1218         }
1219     }
1220     protected void mergeDeveloper_Id(Developer.Builder builder, Developer target, Developer source, boolean sourceDominant, Map<Object, Object> context) {
1221         String src = source.getId();
1222         String tgt = target.getId();
1223         if (src != null && (sourceDominant || tgt == null)) {
1224             builder.id(src);
1225             builder.location("id", source.getLocation("id"));
1226         }
1227     }
1228 
1229     protected Exclusion mergeExclusion(Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context) {
1230         Exclusion.Builder builder = Exclusion.newBuilder(target);
1231         mergeExclusion(builder, target, source, sourceDominant, context);
1232         return builder.build();
1233     }
1234 
1235     protected void mergeExclusion(Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context) {
1236         mergeExclusion_GroupId(builder, target, source, sourceDominant, context);
1237         mergeExclusion_ArtifactId(builder, target, source, sourceDominant, context);
1238     }
1239 
1240     protected void mergeExclusion_GroupId(Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context) {
1241         String src = source.getGroupId();
1242         String tgt = target.getGroupId();
1243         if (src != null && (sourceDominant || tgt == null)) {
1244             builder.groupId(src);
1245             builder.location("groupId", source.getLocation("groupId"));
1246         }
1247     }
1248     protected void mergeExclusion_ArtifactId(Exclusion.Builder builder, Exclusion target, Exclusion source, boolean sourceDominant, Map<Object, Object> context) {
1249         String src = source.getArtifactId();
1250         String tgt = target.getArtifactId();
1251         if (src != null && (sourceDominant || tgt == null)) {
1252             builder.artifactId(src);
1253             builder.location("artifactId", source.getLocation("artifactId"));
1254         }
1255     }
1256 
1257     protected IssueManagement mergeIssueManagement(IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context) {
1258         IssueManagement.Builder builder = IssueManagement.newBuilder(target);
1259         mergeIssueManagement(builder, target, source, sourceDominant, context);
1260         return builder.build();
1261     }
1262 
1263     protected void mergeIssueManagement(IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context) {
1264         mergeIssueManagement_System(builder, target, source, sourceDominant, context);
1265         mergeIssueManagement_Url(builder, target, source, sourceDominant, context);
1266     }
1267 
1268     protected void mergeIssueManagement_System(IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context) {
1269         String src = source.getSystem();
1270         String tgt = target.getSystem();
1271         if (src != null && (sourceDominant || tgt == null)) {
1272             builder.system(src);
1273             builder.location("system", source.getLocation("system"));
1274         }
1275     }
1276     protected void mergeIssueManagement_Url(IssueManagement.Builder builder, IssueManagement target, IssueManagement source, boolean sourceDominant, Map<Object, Object> context) {
1277         String src = source.getUrl();
1278         String tgt = target.getUrl();
1279         if (src != null && (sourceDominant || tgt == null)) {
1280             builder.url(src);
1281             builder.location("url", source.getLocation("url"));
1282         }
1283     }
1284 
1285     protected DistributionManagement mergeDistributionManagement(DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1286         DistributionManagement.Builder builder = DistributionManagement.newBuilder(target);
1287         mergeDistributionManagement(builder, target, source, sourceDominant, context);
1288         return builder.build();
1289     }
1290 
1291     protected void mergeDistributionManagement(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1292         mergeDistributionManagement_Repository(builder, target, source, sourceDominant, context);
1293         mergeDistributionManagement_SnapshotRepository(builder, target, source, sourceDominant, context);
1294         mergeDistributionManagement_Site(builder, target, source, sourceDominant, context);
1295         mergeDistributionManagement_DownloadUrl(builder, target, source, sourceDominant, context);
1296         mergeDistributionManagement_Relocation(builder, target, source, sourceDominant, context);
1297         mergeDistributionManagement_Status(builder, target, source, sourceDominant, context);
1298     }
1299 
1300     protected void mergeDistributionManagement_Repository(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1301         DeploymentRepository src = source.getRepository();
1302         if (src != null) {
1303             DeploymentRepository tgt = target.getRepository();
1304             if (tgt == null) {
1305                 tgt = DeploymentRepository.newInstance(false);
1306             }
1307             DeploymentRepository merged = mergeDeploymentRepository(tgt, src, sourceDominant, context);
1308             builder.repository(merged);
1309             if (target.getRepository() == null) {
1310                 builder.location("repository", source.getLocation("repository"));
1311             } else if (merged != tgt) {
1312                 builder.location("repository", new InputLocation(-1, -1));
1313             }
1314         }
1315     }
1316     protected void mergeDistributionManagement_SnapshotRepository(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1317         DeploymentRepository src = source.getSnapshotRepository();
1318         if (src != null) {
1319             DeploymentRepository tgt = target.getSnapshotRepository();
1320             if (tgt == null) {
1321                 tgt = DeploymentRepository.newInstance(false);
1322             }
1323             DeploymentRepository merged = mergeDeploymentRepository(tgt, src, sourceDominant, context);
1324             builder.snapshotRepository(merged);
1325             if (target.getSnapshotRepository() == null) {
1326                 builder.location("snapshotRepository", source.getLocation("snapshotRepository"));
1327             } else if (merged != tgt) {
1328                 builder.location("snapshotRepository", new InputLocation(-1, -1));
1329             }
1330         }
1331     }
1332     protected void mergeDistributionManagement_Site(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1333         Site src = source.getSite();
1334         if (src != null) {
1335             Site tgt = target.getSite();
1336             if (tgt == null) {
1337                 tgt = Site.newInstance(false);
1338             }
1339             Site merged = mergeSite(tgt, src, sourceDominant, context);
1340             builder.site(merged);
1341             if (target.getSite() == null) {
1342                 builder.location("site", source.getLocation("site"));
1343             } else if (merged != tgt) {
1344                 builder.location("site", new InputLocation(-1, -1));
1345             }
1346         }
1347     }
1348     protected void mergeDistributionManagement_DownloadUrl(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1349         String src = source.getDownloadUrl();
1350         String tgt = target.getDownloadUrl();
1351         if (src != null && (sourceDominant || tgt == null)) {
1352             builder.downloadUrl(src);
1353             builder.location("downloadUrl", source.getLocation("downloadUrl"));
1354         }
1355     }
1356     protected void mergeDistributionManagement_Relocation(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1357         Relocation src = source.getRelocation();
1358         if (src != null) {
1359             Relocation tgt = target.getRelocation();
1360             if (tgt == null) {
1361                 tgt = Relocation.newInstance(false);
1362             }
1363             Relocation merged = mergeRelocation(tgt, src, sourceDominant, context);
1364             builder.relocation(merged);
1365             if (target.getRelocation() == null) {
1366                 builder.location("relocation", source.getLocation("relocation"));
1367             } else if (merged != tgt) {
1368                 builder.location("relocation", new InputLocation(-1, -1));
1369             }
1370         }
1371     }
1372     protected void mergeDistributionManagement_Status(DistributionManagement.Builder builder, DistributionManagement target, DistributionManagement source, boolean sourceDominant, Map<Object, Object> context) {
1373         String src = source.getStatus();
1374         String tgt = target.getStatus();
1375         if (src != null && (sourceDominant || tgt == null)) {
1376             builder.status(src);
1377             builder.location("status", source.getLocation("status"));
1378         }
1379     }
1380 
1381     protected License mergeLicense(License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1382         License.Builder builder = License.newBuilder(target);
1383         mergeLicense(builder, target, source, sourceDominant, context);
1384         return builder.build();
1385     }
1386 
1387     protected void mergeLicense(License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1388         mergeLicense_Name(builder, target, source, sourceDominant, context);
1389         mergeLicense_Url(builder, target, source, sourceDominant, context);
1390         mergeLicense_Distribution(builder, target, source, sourceDominant, context);
1391         mergeLicense_Comments(builder, target, source, sourceDominant, context);
1392     }
1393 
1394     protected void mergeLicense_Name(License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1395         String src = source.getName();
1396         String tgt = target.getName();
1397         if (src != null && (sourceDominant || tgt == null)) {
1398             builder.name(src);
1399             builder.location("name", source.getLocation("name"));
1400         }
1401     }
1402     protected void mergeLicense_Url(License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1403         String src = source.getUrl();
1404         String tgt = target.getUrl();
1405         if (src != null && (sourceDominant || tgt == null)) {
1406             builder.url(src);
1407             builder.location("url", source.getLocation("url"));
1408         }
1409     }
1410     protected void mergeLicense_Distribution(License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1411         String src = source.getDistribution();
1412         String tgt = target.getDistribution();
1413         if (src != null && (sourceDominant || tgt == null)) {
1414             builder.distribution(src);
1415             builder.location("distribution", source.getLocation("distribution"));
1416         }
1417     }
1418     protected void mergeLicense_Comments(License.Builder builder, License target, License source, boolean sourceDominant, Map<Object, Object> context) {
1419         String src = source.getComments();
1420         String tgt = target.getComments();
1421         if (src != null && (sourceDominant || tgt == null)) {
1422             builder.comments(src);
1423             builder.location("comments", source.getLocation("comments"));
1424         }
1425     }
1426 
1427     protected MailingList mergeMailingList(MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1428         MailingList.Builder builder = MailingList.newBuilder(target);
1429         mergeMailingList(builder, target, source, sourceDominant, context);
1430         return builder.build();
1431     }
1432 
1433     protected void mergeMailingList(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1434         mergeMailingList_Name(builder, target, source, sourceDominant, context);
1435         mergeMailingList_Subscribe(builder, target, source, sourceDominant, context);
1436         mergeMailingList_Unsubscribe(builder, target, source, sourceDominant, context);
1437         mergeMailingList_Post(builder, target, source, sourceDominant, context);
1438         mergeMailingList_Archive(builder, target, source, sourceDominant, context);
1439         mergeMailingList_OtherArchives(builder, target, source, sourceDominant, context);
1440     }
1441 
1442     protected void mergeMailingList_Name(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1443         String src = source.getName();
1444         String tgt = target.getName();
1445         if (src != null && (sourceDominant || tgt == null)) {
1446             builder.name(src);
1447             builder.location("name", source.getLocation("name"));
1448         }
1449     }
1450     protected void mergeMailingList_Subscribe(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1451         String src = source.getSubscribe();
1452         String tgt = target.getSubscribe();
1453         if (src != null && (sourceDominant || tgt == null)) {
1454             builder.subscribe(src);
1455             builder.location("subscribe", source.getLocation("subscribe"));
1456         }
1457     }
1458     protected void mergeMailingList_Unsubscribe(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1459         String src = source.getUnsubscribe();
1460         String tgt = target.getUnsubscribe();
1461         if (src != null && (sourceDominant || tgt == null)) {
1462             builder.unsubscribe(src);
1463             builder.location("unsubscribe", source.getLocation("unsubscribe"));
1464         }
1465     }
1466     protected void mergeMailingList_Post(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1467         String src = source.getPost();
1468         String tgt = target.getPost();
1469         if (src != null && (sourceDominant || tgt == null)) {
1470             builder.post(src);
1471             builder.location("post", source.getLocation("post"));
1472         }
1473     }
1474     protected void mergeMailingList_Archive(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1475         String src = source.getArchive();
1476         String tgt = target.getArchive();
1477         if (src != null && (sourceDominant || tgt == null)) {
1478             builder.archive(src);
1479             builder.location("archive", source.getLocation("archive"));
1480         }
1481     }
1482     protected void mergeMailingList_OtherArchives(MailingList.Builder builder, MailingList target, MailingList source, boolean sourceDominant, Map<Object, Object> context) {
1483         builder.otherArchives(merge(target.getOtherArchives(), source.getOtherArchives(), sourceDominant, e -> e));
1484     }
1485 
1486     protected Organization mergeOrganization(Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context) {
1487         Organization.Builder builder = Organization.newBuilder(target);
1488         mergeOrganization(builder, target, source, sourceDominant, context);
1489         return builder.build();
1490     }
1491 
1492     protected void mergeOrganization(Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context) {
1493         mergeOrganization_Name(builder, target, source, sourceDominant, context);
1494         mergeOrganization_Url(builder, target, source, sourceDominant, context);
1495     }
1496 
1497     protected void mergeOrganization_Name(Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context) {
1498         String src = source.getName();
1499         String tgt = target.getName();
1500         if (src != null && (sourceDominant || tgt == null)) {
1501             builder.name(src);
1502             builder.location("name", source.getLocation("name"));
1503         }
1504     }
1505     protected void mergeOrganization_Url(Organization.Builder builder, Organization target, Organization source, boolean sourceDominant, Map<Object, Object> context) {
1506         String src = source.getUrl();
1507         String tgt = target.getUrl();
1508         if (src != null && (sourceDominant || tgt == null)) {
1509             builder.url(src);
1510             builder.location("url", source.getLocation("url"));
1511         }
1512     }
1513 
1514     protected PatternSet mergePatternSet(PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context) {
1515         PatternSet.Builder builder = PatternSet.newBuilder(target);
1516         mergePatternSet(builder, target, source, sourceDominant, context);
1517         return builder.build();
1518     }
1519 
1520     protected void mergePatternSet(PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context) {
1521         mergePatternSet_Includes(builder, target, source, sourceDominant, context);
1522         mergePatternSet_Excludes(builder, target, source, sourceDominant, context);
1523     }
1524 
1525     protected void mergePatternSet_Includes(PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context) {
1526         builder.includes(merge(target.getIncludes(), source.getIncludes(), sourceDominant, e -> e));
1527     }
1528     protected void mergePatternSet_Excludes(PatternSet.Builder builder, PatternSet target, PatternSet source, boolean sourceDominant, Map<Object, Object> context) {
1529         builder.excludes(merge(target.getExcludes(), source.getExcludes(), sourceDominant, e -> e));
1530     }
1531 
1532     protected Parent mergeParent(Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1533         Parent.Builder builder = Parent.newBuilder(target);
1534         mergeParent(builder, target, source, sourceDominant, context);
1535         return builder.build();
1536     }
1537 
1538     protected void mergeParent(Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1539         mergeParent_GroupId(builder, target, source, sourceDominant, context);
1540         mergeParent_ArtifactId(builder, target, source, sourceDominant, context);
1541         mergeParent_Version(builder, target, source, sourceDominant, context);
1542         mergeParent_RelativePath(builder, target, source, sourceDominant, context);
1543     }
1544 
1545     protected void mergeParent_GroupId(Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1546         String src = source.getGroupId();
1547         String tgt = target.getGroupId();
1548         if (src != null && (sourceDominant || tgt == null)) {
1549             builder.groupId(src);
1550             builder.location("groupId", source.getLocation("groupId"));
1551         }
1552     }
1553     protected void mergeParent_ArtifactId(Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1554         String src = source.getArtifactId();
1555         String tgt = target.getArtifactId();
1556         if (src != null && (sourceDominant || tgt == null)) {
1557             builder.artifactId(src);
1558             builder.location("artifactId", source.getLocation("artifactId"));
1559         }
1560     }
1561     protected void mergeParent_Version(Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1562         String src = source.getVersion();
1563         String tgt = target.getVersion();
1564         if (src != null && (sourceDominant || tgt == null)) {
1565             builder.version(src);
1566             builder.location("version", source.getLocation("version"));
1567         }
1568     }
1569     protected void mergeParent_RelativePath(Parent.Builder builder, Parent target, Parent source, boolean sourceDominant, Map<Object, Object> context) {
1570         String src = source.getRelativePath();
1571         String tgt = target.getRelativePath();
1572         if (src != null && (sourceDominant || tgt == null)) {
1573             builder.relativePath(src);
1574             builder.location("relativePath", source.getLocation("relativePath"));
1575         }
1576     }
1577 
1578     protected Scm mergeScm(Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1579         Scm.Builder builder = Scm.newBuilder(target);
1580         mergeScm(builder, target, source, sourceDominant, context);
1581         return builder.build();
1582     }
1583 
1584     protected void mergeScm(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1585         mergeScm_Connection(builder, target, source, sourceDominant, context);
1586         mergeScm_DeveloperConnection(builder, target, source, sourceDominant, context);
1587         mergeScm_Tag(builder, target, source, sourceDominant, context);
1588         mergeScm_Url(builder, target, source, sourceDominant, context);
1589         mergeScm_ChildScmConnectionInheritAppendPath(builder, target, source, sourceDominant, context);
1590         mergeScm_ChildScmDeveloperConnectionInheritAppendPath(builder, target, source, sourceDominant, context);
1591         mergeScm_ChildScmUrlInheritAppendPath(builder, target, source, sourceDominant, context);
1592     }
1593 
1594     protected void mergeScm_Connection(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1595         String src = source.getConnection();
1596         String tgt = target.getConnection();
1597         if (src != null && (sourceDominant || tgt == null)) {
1598             builder.connection(src);
1599             builder.location("connection", source.getLocation("connection"));
1600         }
1601     }
1602     protected void mergeScm_DeveloperConnection(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1603         String src = source.getDeveloperConnection();
1604         String tgt = target.getDeveloperConnection();
1605         if (src != null && (sourceDominant || tgt == null)) {
1606             builder.developerConnection(src);
1607             builder.location("developerConnection", source.getLocation("developerConnection"));
1608         }
1609     }
1610     protected void mergeScm_Tag(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1611         String src = source.getTag();
1612         String tgt = target.getTag();
1613         if (src != null && (sourceDominant || tgt == null)) {
1614             builder.tag(src);
1615             builder.location("tag", source.getLocation("tag"));
1616         }
1617     }
1618     protected void mergeScm_Url(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1619         String src = source.getUrl();
1620         String tgt = target.getUrl();
1621         if (src != null && (sourceDominant || tgt == null)) {
1622             builder.url(src);
1623             builder.location("url", source.getLocation("url"));
1624         }
1625     }
1626     protected void mergeScm_ChildScmConnectionInheritAppendPath(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1627         String src = source.getChildScmConnectionInheritAppendPath();
1628         String tgt = target.getChildScmConnectionInheritAppendPath();
1629         if (src != null && (sourceDominant || tgt == null)) {
1630             builder.childScmConnectionInheritAppendPath(src);
1631             builder.location("childScmConnectionInheritAppendPath", source.getLocation("childScmConnectionInheritAppendPath"));
1632         }
1633     }
1634     protected void mergeScm_ChildScmDeveloperConnectionInheritAppendPath(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1635         String src = source.getChildScmDeveloperConnectionInheritAppendPath();
1636         String tgt = target.getChildScmDeveloperConnectionInheritAppendPath();
1637         if (src != null && (sourceDominant || tgt == null)) {
1638             builder.childScmDeveloperConnectionInheritAppendPath(src);
1639             builder.location("childScmDeveloperConnectionInheritAppendPath", source.getLocation("childScmDeveloperConnectionInheritAppendPath"));
1640         }
1641     }
1642     protected void mergeScm_ChildScmUrlInheritAppendPath(Scm.Builder builder, Scm target, Scm source, boolean sourceDominant, Map<Object, Object> context) {
1643         String src = source.getChildScmUrlInheritAppendPath();
1644         String tgt = target.getChildScmUrlInheritAppendPath();
1645         if (src != null && (sourceDominant || tgt == null)) {
1646             builder.childScmUrlInheritAppendPath(src);
1647             builder.location("childScmUrlInheritAppendPath", source.getLocation("childScmUrlInheritAppendPath"));
1648         }
1649     }
1650 
1651     protected FileSet mergeFileSet(FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context) {
1652         FileSet.Builder builder = FileSet.newBuilder(target);
1653         mergeFileSet(builder, target, source, sourceDominant, context);
1654         return builder.build();
1655     }
1656 
1657     protected void mergeFileSet(FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context) {
1658         mergePatternSet(builder, target, source, sourceDominant, context);
1659         mergeFileSet_Directory(builder, target, source, sourceDominant, context);
1660     }
1661 
1662     protected void mergeFileSet_Includes(FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context) {
1663         builder.includes(merge(target.getIncludes(), source.getIncludes(), sourceDominant, e -> e));
1664     }
1665     protected void mergeFileSet_Excludes(FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context) {
1666         builder.excludes(merge(target.getExcludes(), source.getExcludes(), sourceDominant, e -> e));
1667     }
1668     protected void mergeFileSet_Directory(FileSet.Builder builder, FileSet target, FileSet source, boolean sourceDominant, Map<Object, Object> context) {
1669         String src = source.getDirectory();
1670         String tgt = target.getDirectory();
1671         if (src != null && (sourceDominant || tgt == null)) {
1672             builder.directory(src);
1673             builder.location("directory", source.getLocation("directory"));
1674         }
1675     }
1676 
1677     protected Resource mergeResource(Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1678         Resource.Builder builder = Resource.newBuilder(target);
1679         mergeResource(builder, target, source, sourceDominant, context);
1680         return builder.build();
1681     }
1682 
1683     protected void mergeResource(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1684         mergeFileSet(builder, target, source, sourceDominant, context);
1685         mergeResource_TargetPath(builder, target, source, sourceDominant, context);
1686         mergeResource_Filtering(builder, target, source, sourceDominant, context);
1687         mergeResource_MergeId(builder, target, source, sourceDominant, context);
1688     }
1689 
1690     protected void mergeResource_Includes(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1691         builder.includes(merge(target.getIncludes(), source.getIncludes(), sourceDominant, e -> e));
1692     }
1693     protected void mergeResource_Excludes(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1694         builder.excludes(merge(target.getExcludes(), source.getExcludes(), sourceDominant, e -> e));
1695     }
1696     protected void mergeResource_Directory(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1697         String src = source.getDirectory();
1698         String tgt = target.getDirectory();
1699         if (src != null && (sourceDominant || tgt == null)) {
1700             builder.directory(src);
1701             builder.location("directory", source.getLocation("directory"));
1702         }
1703     }
1704     protected void mergeResource_TargetPath(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1705         String src = source.getTargetPath();
1706         String tgt = target.getTargetPath();
1707         if (src != null && (sourceDominant || tgt == null)) {
1708             builder.targetPath(src);
1709             builder.location("targetPath", source.getLocation("targetPath"));
1710         }
1711     }
1712     protected void mergeResource_Filtering(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1713         String src = source.getFiltering();
1714         String tgt = target.getFiltering();
1715         if (src != null && (sourceDominant || tgt == null)) {
1716             builder.filtering(src);
1717             builder.location("filtering", source.getLocation("filtering"));
1718         }
1719     }
1720     protected void mergeResource_MergeId(Resource.Builder builder, Resource target, Resource source, boolean sourceDominant, Map<Object, Object> context) {
1721         String src = source.getMergeId();
1722         String tgt = target.getMergeId();
1723         if (src != null && (sourceDominant || tgt == null)) {
1724             builder.mergeId(src);
1725             builder.location("mergeId", source.getLocation("mergeId"));
1726         }
1727     }
1728 
1729     protected RepositoryBase mergeRepositoryBase(RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1730         RepositoryBase.Builder builder = RepositoryBase.newBuilder(target);
1731         mergeRepositoryBase(builder, target, source, sourceDominant, context);
1732         return builder.build();
1733     }
1734 
1735     protected void mergeRepositoryBase(RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1736         mergeRepositoryBase_Id(builder, target, source, sourceDominant, context);
1737         mergeRepositoryBase_Name(builder, target, source, sourceDominant, context);
1738         mergeRepositoryBase_Url(builder, target, source, sourceDominant, context);
1739         mergeRepositoryBase_Layout(builder, target, source, sourceDominant, context);
1740     }
1741 
1742     protected void mergeRepositoryBase_Id(RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1743         String src = source.getId();
1744         String tgt = target.getId();
1745         if (src != null && (sourceDominant || tgt == null)) {
1746             builder.id(src);
1747             builder.location("id", source.getLocation("id"));
1748         }
1749     }
1750     protected void mergeRepositoryBase_Name(RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1751         String src = source.getName();
1752         String tgt = target.getName();
1753         if (src != null && (sourceDominant || tgt == null)) {
1754             builder.name(src);
1755             builder.location("name", source.getLocation("name"));
1756         }
1757     }
1758     protected void mergeRepositoryBase_Url(RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1759         String src = source.getUrl();
1760         String tgt = target.getUrl();
1761         if (src != null && (sourceDominant || tgt == null)) {
1762             builder.url(src);
1763             builder.location("url", source.getLocation("url"));
1764         }
1765     }
1766     protected void mergeRepositoryBase_Layout(RepositoryBase.Builder builder, RepositoryBase target, RepositoryBase source, boolean sourceDominant, Map<Object, Object> context) {
1767         String src = source.getLayout();
1768         String tgt = target.getLayout();
1769         if (src != null && (sourceDominant || tgt == null)) {
1770             builder.layout(src);
1771             builder.location("layout", source.getLocation("layout"));
1772         }
1773     }
1774 
1775     protected Repository mergeRepository(Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1776         Repository.Builder builder = Repository.newBuilder(target);
1777         mergeRepository(builder, target, source, sourceDominant, context);
1778         return builder.build();
1779     }
1780 
1781     protected void mergeRepository(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1782         mergeRepositoryBase(builder, target, source, sourceDominant, context);
1783         mergeRepository_Releases(builder, target, source, sourceDominant, context);
1784         mergeRepository_Snapshots(builder, target, source, sourceDominant, context);
1785     }
1786 
1787     protected void mergeRepository_Id(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1788         String src = source.getId();
1789         String tgt = target.getId();
1790         if (src != null && (sourceDominant || tgt == null)) {
1791             builder.id(src);
1792             builder.location("id", source.getLocation("id"));
1793         }
1794     }
1795     protected void mergeRepository_Name(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1796         String src = source.getName();
1797         String tgt = target.getName();
1798         if (src != null && (sourceDominant || tgt == null)) {
1799             builder.name(src);
1800             builder.location("name", source.getLocation("name"));
1801         }
1802     }
1803     protected void mergeRepository_Url(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1804         String src = source.getUrl();
1805         String tgt = target.getUrl();
1806         if (src != null && (sourceDominant || tgt == null)) {
1807             builder.url(src);
1808             builder.location("url", source.getLocation("url"));
1809         }
1810     }
1811     protected void mergeRepository_Layout(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1812         String src = source.getLayout();
1813         String tgt = target.getLayout();
1814         if (src != null && (sourceDominant || tgt == null)) {
1815             builder.layout(src);
1816             builder.location("layout", source.getLocation("layout"));
1817         }
1818     }
1819     protected void mergeRepository_Releases(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1820         RepositoryPolicy src = source.getReleases();
1821         if (src != null) {
1822             RepositoryPolicy tgt = target.getReleases();
1823             if (tgt == null) {
1824                 tgt = RepositoryPolicy.newInstance(false);
1825             }
1826             RepositoryPolicy merged = mergeRepositoryPolicy(tgt, src, sourceDominant, context);
1827             builder.releases(merged);
1828             if (target.getReleases() == null) {
1829                 builder.location("releases", source.getLocation("releases"));
1830             } else if (merged != tgt) {
1831                 builder.location("releases", new InputLocation(-1, -1));
1832             }
1833         }
1834     }
1835     protected void mergeRepository_Snapshots(Repository.Builder builder, Repository target, Repository source, boolean sourceDominant, Map<Object, Object> context) {
1836         RepositoryPolicy src = source.getSnapshots();
1837         if (src != null) {
1838             RepositoryPolicy tgt = target.getSnapshots();
1839             if (tgt == null) {
1840                 tgt = RepositoryPolicy.newInstance(false);
1841             }
1842             RepositoryPolicy merged = mergeRepositoryPolicy(tgt, src, sourceDominant, context);
1843             builder.snapshots(merged);
1844             if (target.getSnapshots() == null) {
1845                 builder.location("snapshots", source.getLocation("snapshots"));
1846             } else if (merged != tgt) {
1847                 builder.location("snapshots", new InputLocation(-1, -1));
1848             }
1849         }
1850     }
1851 
1852     protected DeploymentRepository mergeDeploymentRepository(DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1853         DeploymentRepository.Builder builder = DeploymentRepository.newBuilder(target);
1854         mergeDeploymentRepository(builder, target, source, sourceDominant, context);
1855         return builder.build();
1856     }
1857 
1858     protected void mergeDeploymentRepository(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1859         mergeRepository(builder, target, source, sourceDominant, context);
1860         mergeDeploymentRepository_UniqueVersion(builder, target, source, sourceDominant, context);
1861     }
1862 
1863     protected void mergeDeploymentRepository_Id(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1864         String src = source.getId();
1865         String tgt = target.getId();
1866         if (src != null && (sourceDominant || tgt == null)) {
1867             builder.id(src);
1868             builder.location("id", source.getLocation("id"));
1869         }
1870     }
1871     protected void mergeDeploymentRepository_Name(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1872         String src = source.getName();
1873         String tgt = target.getName();
1874         if (src != null && (sourceDominant || tgt == null)) {
1875             builder.name(src);
1876             builder.location("name", source.getLocation("name"));
1877         }
1878     }
1879     protected void mergeDeploymentRepository_Url(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1880         String src = source.getUrl();
1881         String tgt = target.getUrl();
1882         if (src != null && (sourceDominant || tgt == null)) {
1883             builder.url(src);
1884             builder.location("url", source.getLocation("url"));
1885         }
1886     }
1887     protected void mergeDeploymentRepository_Layout(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1888         String src = source.getLayout();
1889         String tgt = target.getLayout();
1890         if (src != null && (sourceDominant || tgt == null)) {
1891             builder.layout(src);
1892             builder.location("layout", source.getLocation("layout"));
1893         }
1894     }
1895     protected void mergeDeploymentRepository_Releases(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1896         RepositoryPolicy src = source.getReleases();
1897         if (src != null) {
1898             RepositoryPolicy tgt = target.getReleases();
1899             if (tgt == null) {
1900                 tgt = RepositoryPolicy.newInstance(false);
1901             }
1902             RepositoryPolicy merged = mergeRepositoryPolicy(tgt, src, sourceDominant, context);
1903             builder.releases(merged);
1904             if (target.getReleases() == null) {
1905                 builder.location("releases", source.getLocation("releases"));
1906             } else if (merged != tgt) {
1907                 builder.location("releases", new InputLocation(-1, -1));
1908             }
1909         }
1910     }
1911     protected void mergeDeploymentRepository_Snapshots(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1912         RepositoryPolicy src = source.getSnapshots();
1913         if (src != null) {
1914             RepositoryPolicy tgt = target.getSnapshots();
1915             if (tgt == null) {
1916                 tgt = RepositoryPolicy.newInstance(false);
1917             }
1918             RepositoryPolicy merged = mergeRepositoryPolicy(tgt, src, sourceDominant, context);
1919             builder.snapshots(merged);
1920             if (target.getSnapshots() == null) {
1921                 builder.location("snapshots", source.getLocation("snapshots"));
1922             } else if (merged != tgt) {
1923                 builder.location("snapshots", new InputLocation(-1, -1));
1924             }
1925         }
1926     }
1927     protected void mergeDeploymentRepository_UniqueVersion(DeploymentRepository.Builder builder, DeploymentRepository target, DeploymentRepository source, boolean sourceDominant, Map<Object, Object> context) {
1928         if (sourceDominant) {
1929             builder.uniqueVersion(source.isUniqueVersion());
1930         }
1931     }
1932 
1933     protected RepositoryPolicy mergeRepositoryPolicy(RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context) {
1934         RepositoryPolicy.Builder builder = RepositoryPolicy.newBuilder(target);
1935         mergeRepositoryPolicy(builder, target, source, sourceDominant, context);
1936         return builder.build();
1937     }
1938 
1939     protected void mergeRepositoryPolicy(RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context) {
1940         mergeRepositoryPolicy_Enabled(builder, target, source, sourceDominant, context);
1941         mergeRepositoryPolicy_UpdatePolicy(builder, target, source, sourceDominant, context);
1942         mergeRepositoryPolicy_ChecksumPolicy(builder, target, source, sourceDominant, context);
1943     }
1944 
1945     protected void mergeRepositoryPolicy_Enabled(RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context) {
1946         String src = source.getEnabled();
1947         String tgt = target.getEnabled();
1948         if (src != null && (sourceDominant || tgt == null)) {
1949             builder.enabled(src);
1950             builder.location("enabled", source.getLocation("enabled"));
1951         }
1952     }
1953     protected void mergeRepositoryPolicy_UpdatePolicy(RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context) {
1954         String src = source.getUpdatePolicy();
1955         String tgt = target.getUpdatePolicy();
1956         if (src != null && (sourceDominant || tgt == null)) {
1957             builder.updatePolicy(src);
1958             builder.location("updatePolicy", source.getLocation("updatePolicy"));
1959         }
1960     }
1961     protected void mergeRepositoryPolicy_ChecksumPolicy(RepositoryPolicy.Builder builder, RepositoryPolicy target, RepositoryPolicy source, boolean sourceDominant, Map<Object, Object> context) {
1962         String src = source.getChecksumPolicy();
1963         String tgt = target.getChecksumPolicy();
1964         if (src != null && (sourceDominant || tgt == null)) {
1965             builder.checksumPolicy(src);
1966             builder.location("checksumPolicy", source.getLocation("checksumPolicy"));
1967         }
1968     }
1969 
1970     protected Site mergeSite(Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
1971         Site.Builder builder = Site.newBuilder(target);
1972         mergeSite(builder, target, source, sourceDominant, context);
1973         return builder.build();
1974     }
1975 
1976     protected void mergeSite(Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
1977         mergeSite_Id(builder, target, source, sourceDominant, context);
1978         mergeSite_Name(builder, target, source, sourceDominant, context);
1979         mergeSite_Url(builder, target, source, sourceDominant, context);
1980         mergeSite_ChildSiteUrlInheritAppendPath(builder, target, source, sourceDominant, context);
1981     }
1982 
1983     protected void mergeSite_Id(Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
1984         String src = source.getId();
1985         String tgt = target.getId();
1986         if (src != null && (sourceDominant || tgt == null)) {
1987             builder.id(src);
1988             builder.location("id", source.getLocation("id"));
1989         }
1990     }
1991     protected void mergeSite_Name(Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
1992         String src = source.getName();
1993         String tgt = target.getName();
1994         if (src != null && (sourceDominant || tgt == null)) {
1995             builder.name(src);
1996             builder.location("name", source.getLocation("name"));
1997         }
1998     }
1999     protected void mergeSite_Url(Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
2000         String src = source.getUrl();
2001         String tgt = target.getUrl();
2002         if (src != null && (sourceDominant || tgt == null)) {
2003             builder.url(src);
2004             builder.location("url", source.getLocation("url"));
2005         }
2006     }
2007     protected void mergeSite_ChildSiteUrlInheritAppendPath(Site.Builder builder, Site target, Site source, boolean sourceDominant, Map<Object, Object> context) {
2008         String src = source.getChildSiteUrlInheritAppendPath();
2009         String tgt = target.getChildSiteUrlInheritAppendPath();
2010         if (src != null && (sourceDominant || tgt == null)) {
2011             builder.childSiteUrlInheritAppendPath(src);
2012             builder.location("childSiteUrlInheritAppendPath", source.getLocation("childSiteUrlInheritAppendPath"));
2013         }
2014     }
2015 
2016     protected ConfigurationContainer mergeConfigurationContainer(ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context) {
2017         ConfigurationContainer.Builder builder = ConfigurationContainer.newBuilder(target);
2018         mergeConfigurationContainer(builder, target, source, sourceDominant, context);
2019         return builder.build();
2020     }
2021 
2022     protected void mergeConfigurationContainer(ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context) {
2023         mergeConfigurationContainer_Inherited(builder, target, source, sourceDominant, context);
2024         mergeConfigurationContainer_Configuration(builder, target, source, sourceDominant, context);
2025     }
2026 
2027     protected void mergeConfigurationContainer_Inherited(ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context) {
2028         String src = source.getInherited();
2029         String tgt = target.getInherited();
2030         if (src != null && (sourceDominant || tgt == null)) {
2031             builder.inherited(src);
2032             builder.location("inherited", source.getLocation("inherited"));
2033         }
2034     }
2035     protected void mergeConfigurationContainer_Configuration(ConfigurationContainer.Builder builder, ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context) {
2036         XmlNode src = source.getConfiguration();
2037         if (src != null) {
2038             XmlNode tgt = target.getConfiguration();
2039             if (tgt == null) {
2040                 builder.configuration(src);
2041                 builder.location("configuration", source.getLocation("configuration"));
2042             } else if (sourceDominant) {
2043                 builder.configuration(src.merge(tgt));
2044                 builder.location("configuration", target.getLocation("configuration"));
2045             } else {
2046                 builder.configuration(tgt.merge(src));
2047                 builder.location("configuration", null);
2048             }
2049         }
2050     }
2051 
2052     protected Plugin mergePlugin(Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2053         Plugin.Builder builder = Plugin.newBuilder(target);
2054         mergePlugin(builder, target, source, sourceDominant, context);
2055         return builder.build();
2056     }
2057 
2058     protected void mergePlugin(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2059         mergeConfigurationContainer(builder, target, source, sourceDominant, context);
2060         mergePlugin_GroupId(builder, target, source, sourceDominant, context);
2061         mergePlugin_ArtifactId(builder, target, source, sourceDominant, context);
2062         mergePlugin_Version(builder, target, source, sourceDominant, context);
2063         mergePlugin_Extensions(builder, target, source, sourceDominant, context);
2064         mergePlugin_Executions(builder, target, source, sourceDominant, context);
2065         mergePlugin_Dependencies(builder, target, source, sourceDominant, context);
2066     }
2067 
2068     protected void mergePlugin_Inherited(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2069         String src = source.getInherited();
2070         String tgt = target.getInherited();
2071         if (src != null && (sourceDominant || tgt == null)) {
2072             builder.inherited(src);
2073             builder.location("inherited", source.getLocation("inherited"));
2074         }
2075     }
2076     protected void mergePlugin_Configuration(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2077         XmlNode src = source.getConfiguration();
2078         if (src != null) {
2079             XmlNode tgt = target.getConfiguration();
2080             if (tgt == null) {
2081                 builder.configuration(src);
2082                 builder.location("configuration", source.getLocation("configuration"));
2083             } else if (sourceDominant) {
2084                 builder.configuration(src.merge(tgt));
2085                 builder.location("configuration", target.getLocation("configuration"));
2086             } else {
2087                 builder.configuration(tgt.merge(src));
2088                 builder.location("configuration", null);
2089             }
2090         }
2091     }
2092     protected void mergePlugin_GroupId(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2093         String src = source.getGroupId();
2094         String tgt = target.getGroupId();
2095         if (src != null && (sourceDominant || tgt == null)) {
2096             builder.groupId(src);
2097             builder.location("groupId", source.getLocation("groupId"));
2098         }
2099     }
2100     protected void mergePlugin_ArtifactId(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2101         String src = source.getArtifactId();
2102         String tgt = target.getArtifactId();
2103         if (src != null && (sourceDominant || tgt == null)) {
2104             builder.artifactId(src);
2105             builder.location("artifactId", source.getLocation("artifactId"));
2106         }
2107     }
2108     protected void mergePlugin_Version(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2109         String src = source.getVersion();
2110         String tgt = target.getVersion();
2111         if (src != null && (sourceDominant || tgt == null)) {
2112             builder.version(src);
2113             builder.location("version", source.getLocation("version"));
2114         }
2115     }
2116     protected void mergePlugin_Extensions(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2117         String src = source.getExtensions();
2118         String tgt = target.getExtensions();
2119         if (src != null && (sourceDominant || tgt == null)) {
2120             builder.extensions(src);
2121             builder.location("extensions", source.getLocation("extensions"));
2122         }
2123     }
2124     protected void mergePlugin_Executions(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2125         if (deepMerge) {
2126             builder.executions(merge(target.getExecutions(), source.getExecutions(), getPluginExecutionKey(),
2127                     (t, s) -> mergePluginExecution(t, s, sourceDominant, context)));
2128         } else {
2129             builder.executions(merge(target.getExecutions(), source.getExecutions(), sourceDominant, getPluginExecutionKey()));
2130         }
2131     }
2132     protected void mergePlugin_Dependencies(Plugin.Builder builder, Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context) {
2133         if (deepMerge) {
2134             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), getDependencyKey(),
2135                     (t, s) -> mergeDependency(t, s, sourceDominant, context)));
2136         } else {
2137             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey()));
2138         }
2139     }
2140 
2141     protected PluginExecution mergePluginExecution(PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2142         PluginExecution.Builder builder = PluginExecution.newBuilder(target);
2143         mergePluginExecution(builder, target, source, sourceDominant, context);
2144         return builder.build();
2145     }
2146 
2147     protected void mergePluginExecution(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2148         mergeConfigurationContainer(builder, target, source, sourceDominant, context);
2149         mergePluginExecution_Id(builder, target, source, sourceDominant, context);
2150         mergePluginExecution_Phase(builder, target, source, sourceDominant, context);
2151         mergePluginExecution_Priority(builder, target, source, sourceDominant, context);
2152         mergePluginExecution_Goals(builder, target, source, sourceDominant, context);
2153     }
2154 
2155     protected void mergePluginExecution_Inherited(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2156         String src = source.getInherited();
2157         String tgt = target.getInherited();
2158         if (src != null && (sourceDominant || tgt == null)) {
2159             builder.inherited(src);
2160             builder.location("inherited", source.getLocation("inherited"));
2161         }
2162     }
2163     protected void mergePluginExecution_Configuration(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2164         XmlNode src = source.getConfiguration();
2165         if (src != null) {
2166             XmlNode tgt = target.getConfiguration();
2167             if (tgt == null) {
2168                 builder.configuration(src);
2169                 builder.location("configuration", source.getLocation("configuration"));
2170             } else if (sourceDominant) {
2171                 builder.configuration(src.merge(tgt));
2172                 builder.location("configuration", target.getLocation("configuration"));
2173             } else {
2174                 builder.configuration(tgt.merge(src));
2175                 builder.location("configuration", null);
2176             }
2177         }
2178     }
2179     protected void mergePluginExecution_Id(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2180         String src = source.getId();
2181         String tgt = target.getId();
2182         if (src != null && (sourceDominant || tgt == null)) {
2183             builder.id(src);
2184             builder.location("id", source.getLocation("id"));
2185         }
2186     }
2187     protected void mergePluginExecution_Phase(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2188         String src = source.getPhase();
2189         String tgt = target.getPhase();
2190         if (src != null && (sourceDominant || tgt == null)) {
2191             builder.phase(src);
2192             builder.location("phase", source.getLocation("phase"));
2193         }
2194     }
2195     protected void mergePluginExecution_Priority(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2196         if (sourceDominant) {
2197             builder.priority(source.getPriority());
2198         }
2199     }
2200     protected void mergePluginExecution_Goals(PluginExecution.Builder builder, PluginExecution target, PluginExecution source, boolean sourceDominant, Map<Object, Object> context) {
2201         builder.goals(merge(target.getGoals(), source.getGoals(), sourceDominant, e -> e));
2202     }
2203 
2204     protected DependencyManagement mergeDependencyManagement(DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context) {
2205         DependencyManagement.Builder builder = DependencyManagement.newBuilder(target);
2206         mergeDependencyManagement(builder, target, source, sourceDominant, context);
2207         return builder.build();
2208     }
2209 
2210     protected void mergeDependencyManagement(DependencyManagement.Builder builder, DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context) {
2211         mergeDependencyManagement_Dependencies(builder, target, source, sourceDominant, context);
2212     }
2213 
2214     protected void mergeDependencyManagement_Dependencies(DependencyManagement.Builder builder, DependencyManagement target, DependencyManagement source, boolean sourceDominant, Map<Object, Object> context) {
2215         if (deepMerge) {
2216             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), getDependencyKey(),
2217                     (t, s) -> mergeDependency(t, s, sourceDominant, context)));
2218         } else {
2219             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey()));
2220         }
2221     }
2222 
2223     protected PluginManagement mergePluginManagement(PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context) {
2224         PluginManagement.Builder builder = PluginManagement.newBuilder(target);
2225         mergePluginManagement(builder, target, source, sourceDominant, context);
2226         return builder.build();
2227     }
2228 
2229     protected void mergePluginManagement(PluginManagement.Builder builder, PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context) {
2230         mergePluginContainer(builder, target, source, sourceDominant, context);
2231     }
2232 
2233     protected void mergePluginManagement_Plugins(PluginManagement.Builder builder, PluginManagement target, PluginManagement source, boolean sourceDominant, Map<Object, Object> context) {
2234         if (deepMerge) {
2235             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getPluginKey(),
2236                     (t, s) -> mergePlugin(t, s, sourceDominant, context)));
2237         } else {
2238             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getPluginKey()));
2239         }
2240     }
2241 
2242     protected Reporting mergeReporting(Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context) {
2243         Reporting.Builder builder = Reporting.newBuilder(target);
2244         mergeReporting(builder, target, source, sourceDominant, context);
2245         return builder.build();
2246     }
2247 
2248     protected void mergeReporting(Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context) {
2249         mergeReporting_ExcludeDefaults(builder, target, source, sourceDominant, context);
2250         mergeReporting_OutputDirectory(builder, target, source, sourceDominant, context);
2251         mergeReporting_Plugins(builder, target, source, sourceDominant, context);
2252     }
2253 
2254     protected void mergeReporting_ExcludeDefaults(Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context) {
2255         String src = source.getExcludeDefaults();
2256         String tgt = target.getExcludeDefaults();
2257         if (src != null && (sourceDominant || tgt == null)) {
2258             builder.excludeDefaults(src);
2259             builder.location("excludeDefaults", source.getLocation("excludeDefaults"));
2260         }
2261     }
2262     protected void mergeReporting_OutputDirectory(Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context) {
2263         String src = source.getOutputDirectory();
2264         String tgt = target.getOutputDirectory();
2265         if (src != null && (sourceDominant || tgt == null)) {
2266             builder.outputDirectory(src);
2267             builder.location("outputDirectory", source.getLocation("outputDirectory"));
2268         }
2269     }
2270     protected void mergeReporting_Plugins(Reporting.Builder builder, Reporting target, Reporting source, boolean sourceDominant, Map<Object, Object> context) {
2271         if (deepMerge) {
2272             builder.plugins(merge(target.getPlugins(), source.getPlugins(), getReportPluginKey(),
2273                     (t, s) -> mergeReportPlugin(t, s, sourceDominant, context)));
2274         } else {
2275             builder.plugins(merge(target.getPlugins(), source.getPlugins(), sourceDominant, getReportPluginKey()));
2276         }
2277     }
2278 
2279     protected Profile mergeProfile(Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2280         Profile.Builder builder = Profile.newBuilder(target);
2281         mergeProfile(builder, target, source, sourceDominant, context);
2282         return builder.build();
2283     }
2284 
2285     protected void mergeProfile(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2286         mergeModelBase(builder, target, source, sourceDominant, context);
2287         mergeProfile_Id(builder, target, source, sourceDominant, context);
2288         mergeProfile_Activation(builder, target, source, sourceDominant, context);
2289         mergeProfile_Build(builder, target, source, sourceDominant, context);
2290     }
2291 
2292     protected void mergeProfile_Modules(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2293         builder.modules(merge(target.getModules(), source.getModules(), sourceDominant, e -> e));
2294     }
2295     protected void mergeProfile_DistributionManagement(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2296         DistributionManagement src = source.getDistributionManagement();
2297         if (src != null) {
2298             DistributionManagement tgt = target.getDistributionManagement();
2299             if (tgt == null) {
2300                 tgt = DistributionManagement.newInstance(false);
2301             }
2302             DistributionManagement merged = mergeDistributionManagement(tgt, src, sourceDominant, context);
2303             builder.distributionManagement(merged);
2304             if (target.getDistributionManagement() == null) {
2305                 builder.location("distributionManagement", source.getLocation("distributionManagement"));
2306             } else if (merged != tgt) {
2307                 builder.location("distributionManagement", new InputLocation(-1, -1));
2308             }
2309         }
2310     }
2311     protected void mergeProfile_Properties(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2312         Map<String, String> src = source.getProperties();
2313         if (!src.isEmpty()) {
2314             Map<String, String> tgt = target.getProperties();
2315             if (tgt.isEmpty()) {
2316                 builder.properties(src);
2317                 builder.location("properties", source.getLocation("properties"));
2318             } else {
2319                 Map<String, String> merged = new HashMap<>();
2320                 merged.putAll(sourceDominant ? target.getProperties() : source.getProperties());
2321                 merged.putAll(sourceDominant ? source.getProperties() : target.getProperties());
2322                 builder.properties(merged);
2323                 builder.location("properties", InputLocation.merge(target.getLocation("properties"), source.getLocation("properties"), sourceDominant));
2324             }
2325         }
2326     }
2327     protected void mergeProfile_DependencyManagement(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2328         DependencyManagement src = source.getDependencyManagement();
2329         if (src != null) {
2330             DependencyManagement tgt = target.getDependencyManagement();
2331             if (tgt == null) {
2332                 tgt = DependencyManagement.newInstance(false);
2333             }
2334             DependencyManagement merged = mergeDependencyManagement(tgt, src, sourceDominant, context);
2335             builder.dependencyManagement(merged);
2336             if (target.getDependencyManagement() == null) {
2337                 builder.location("dependencyManagement", source.getLocation("dependencyManagement"));
2338             } else if (merged != tgt) {
2339                 builder.location("dependencyManagement", new InputLocation(-1, -1));
2340             }
2341         }
2342     }
2343     protected void mergeProfile_Dependencies(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2344         if (deepMerge) {
2345             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), getDependencyKey(),
2346                     (t, s) -> mergeDependency(t, s, sourceDominant, context)));
2347         } else {
2348             builder.dependencies(merge(target.getDependencies(), source.getDependencies(), sourceDominant, getDependencyKey()));
2349         }
2350     }
2351     protected void mergeProfile_Repositories(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2352         if (deepMerge) {
2353             builder.repositories(merge(target.getRepositories(), source.getRepositories(), getRepositoryKey(),
2354                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
2355         } else {
2356             builder.repositories(merge(target.getRepositories(), source.getRepositories(), sourceDominant, getRepositoryKey()));
2357         }
2358     }
2359     protected void mergeProfile_PluginRepositories(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2360         if (deepMerge) {
2361             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), getRepositoryKey(),
2362                     (t, s) -> mergeRepository(t, s, sourceDominant, context)));
2363         } else {
2364             builder.pluginRepositories(merge(target.getPluginRepositories(), source.getPluginRepositories(), sourceDominant, getRepositoryKey()));
2365         }
2366     }
2367     protected void mergeProfile_Reporting(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2368         Reporting src = source.getReporting();
2369         if (src != null) {
2370             Reporting tgt = target.getReporting();
2371             if (tgt == null) {
2372                 tgt = Reporting.newInstance(false);
2373             }
2374             Reporting merged = mergeReporting(tgt, src, sourceDominant, context);
2375             builder.reporting(merged);
2376             if (target.getReporting() == null) {
2377                 builder.location("reporting", source.getLocation("reporting"));
2378             } else if (merged != tgt) {
2379                 builder.location("reporting", new InputLocation(-1, -1));
2380             }
2381         }
2382     }
2383     protected void mergeProfile_Id(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2384         String src = source.getId();
2385         String tgt = target.getId();
2386         if (src != null && (sourceDominant || tgt == null)) {
2387             builder.id(src);
2388             builder.location("id", source.getLocation("id"));
2389         }
2390     }
2391     protected void mergeProfile_Activation(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2392         Activation src = source.getActivation();
2393         if (src != null) {
2394             Activation tgt = target.getActivation();
2395             if (tgt == null) {
2396                 tgt = Activation.newInstance(false);
2397             }
2398             Activation merged = mergeActivation(tgt, src, sourceDominant, context);
2399             builder.activation(merged);
2400             if (target.getActivation() == null) {
2401                 builder.location("activation", source.getLocation("activation"));
2402             } else if (merged != tgt) {
2403                 builder.location("activation", new InputLocation(-1, -1));
2404             }
2405         }
2406     }
2407     protected void mergeProfile_Build(Profile.Builder builder, Profile target, Profile source, boolean sourceDominant, Map<Object, Object> context) {
2408         BuildBase src = source.getBuild();
2409         if (src != null) {
2410             BuildBase tgt = target.getBuild();
2411             if (tgt == null) {
2412                 tgt = BuildBase.newInstance(false);
2413             }
2414             BuildBase merged = mergeBuildBase(tgt, src, sourceDominant, context);
2415             builder.build(merged);
2416             if (target.getBuild() == null) {
2417                 builder.location("build", source.getLocation("build"));
2418             } else if (merged != tgt) {
2419                 builder.location("build", new InputLocation(-1, -1));
2420             }
2421         }
2422     }
2423 
2424     protected Activation mergeActivation(Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2425         Activation.Builder builder = Activation.newBuilder(target);
2426         mergeActivation(builder, target, source, sourceDominant, context);
2427         return builder.build();
2428     }
2429 
2430     protected void mergeActivation(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2431         mergeActivation_ActiveByDefault(builder, target, source, sourceDominant, context);
2432         mergeActivation_Jdk(builder, target, source, sourceDominant, context);
2433         mergeActivation_Os(builder, target, source, sourceDominant, context);
2434         mergeActivation_Property(builder, target, source, sourceDominant, context);
2435         mergeActivation_File(builder, target, source, sourceDominant, context);
2436     }
2437 
2438     protected void mergeActivation_ActiveByDefault(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2439         if (sourceDominant) {
2440             builder.activeByDefault(source.isActiveByDefault());
2441         }
2442     }
2443     protected void mergeActivation_Jdk(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2444         String src = source.getJdk();
2445         String tgt = target.getJdk();
2446         if (src != null && (sourceDominant || tgt == null)) {
2447             builder.jdk(src);
2448             builder.location("jdk", source.getLocation("jdk"));
2449         }
2450     }
2451     protected void mergeActivation_Os(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2452         ActivationOS src = source.getOs();
2453         if (src != null) {
2454             ActivationOS tgt = target.getOs();
2455             if (tgt == null) {
2456                 tgt = ActivationOS.newInstance(false);
2457             }
2458             ActivationOS merged = mergeActivationOS(tgt, src, sourceDominant, context);
2459             builder.os(merged);
2460             if (target.getOs() == null) {
2461                 builder.location("os", source.getLocation("os"));
2462             } else if (merged != tgt) {
2463                 builder.location("os", new InputLocation(-1, -1));
2464             }
2465         }
2466     }
2467     protected void mergeActivation_Property(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2468         ActivationProperty src = source.getProperty();
2469         if (src != null) {
2470             ActivationProperty tgt = target.getProperty();
2471             if (tgt == null) {
2472                 tgt = ActivationProperty.newInstance(false);
2473             }
2474             ActivationProperty merged = mergeActivationProperty(tgt, src, sourceDominant, context);
2475             builder.property(merged);
2476             if (target.getProperty() == null) {
2477                 builder.location("property", source.getLocation("property"));
2478             } else if (merged != tgt) {
2479                 builder.location("property", new InputLocation(-1, -1));
2480             }
2481         }
2482     }
2483     protected void mergeActivation_File(Activation.Builder builder, Activation target, Activation source, boolean sourceDominant, Map<Object, Object> context) {
2484         ActivationFile src = source.getFile();
2485         if (src != null) {
2486             ActivationFile tgt = target.getFile();
2487             if (tgt == null) {
2488                 tgt = ActivationFile.newInstance(false);
2489             }
2490             ActivationFile merged = mergeActivationFile(tgt, src, sourceDominant, context);
2491             builder.file(merged);
2492             if (target.getFile() == null) {
2493                 builder.location("file", source.getLocation("file"));
2494             } else if (merged != tgt) {
2495                 builder.location("file", new InputLocation(-1, -1));
2496             }
2497         }
2498     }
2499 
2500     protected ActivationProperty mergeActivationProperty(ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context) {
2501         ActivationProperty.Builder builder = ActivationProperty.newBuilder(target);
2502         mergeActivationProperty(builder, target, source, sourceDominant, context);
2503         return builder.build();
2504     }
2505 
2506     protected void mergeActivationProperty(ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context) {
2507         mergeActivationProperty_Name(builder, target, source, sourceDominant, context);
2508         mergeActivationProperty_Value(builder, target, source, sourceDominant, context);
2509     }
2510 
2511     protected void mergeActivationProperty_Name(ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context) {
2512         String src = source.getName();
2513         String tgt = target.getName();
2514         if (src != null && (sourceDominant || tgt == null)) {
2515             builder.name(src);
2516             builder.location("name", source.getLocation("name"));
2517         }
2518     }
2519     protected void mergeActivationProperty_Value(ActivationProperty.Builder builder, ActivationProperty target, ActivationProperty source, boolean sourceDominant, Map<Object, Object> context) {
2520         String src = source.getValue();
2521         String tgt = target.getValue();
2522         if (src != null && (sourceDominant || tgt == null)) {
2523             builder.value(src);
2524             builder.location("value", source.getLocation("value"));
2525         }
2526     }
2527 
2528     protected ActivationOS mergeActivationOS(ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2529         ActivationOS.Builder builder = ActivationOS.newBuilder(target);
2530         mergeActivationOS(builder, target, source, sourceDominant, context);
2531         return builder.build();
2532     }
2533 
2534     protected void mergeActivationOS(ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2535         mergeActivationOS_Name(builder, target, source, sourceDominant, context);
2536         mergeActivationOS_Family(builder, target, source, sourceDominant, context);
2537         mergeActivationOS_Arch(builder, target, source, sourceDominant, context);
2538         mergeActivationOS_Version(builder, target, source, sourceDominant, context);
2539     }
2540 
2541     protected void mergeActivationOS_Name(ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2542         String src = source.getName();
2543         String tgt = target.getName();
2544         if (src != null && (sourceDominant || tgt == null)) {
2545             builder.name(src);
2546             builder.location("name", source.getLocation("name"));
2547         }
2548     }
2549     protected void mergeActivationOS_Family(ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2550         String src = source.getFamily();
2551         String tgt = target.getFamily();
2552         if (src != null && (sourceDominant || tgt == null)) {
2553             builder.family(src);
2554             builder.location("family", source.getLocation("family"));
2555         }
2556     }
2557     protected void mergeActivationOS_Arch(ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2558         String src = source.getArch();
2559         String tgt = target.getArch();
2560         if (src != null && (sourceDominant || tgt == null)) {
2561             builder.arch(src);
2562             builder.location("arch", source.getLocation("arch"));
2563         }
2564     }
2565     protected void mergeActivationOS_Version(ActivationOS.Builder builder, ActivationOS target, ActivationOS source, boolean sourceDominant, Map<Object, Object> context) {
2566         String src = source.getVersion();
2567         String tgt = target.getVersion();
2568         if (src != null && (sourceDominant || tgt == null)) {
2569             builder.version(src);
2570             builder.location("version", source.getLocation("version"));
2571         }
2572     }
2573 
2574     protected ActivationFile mergeActivationFile(ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context) {
2575         ActivationFile.Builder builder = ActivationFile.newBuilder(target);
2576         mergeActivationFile(builder, target, source, sourceDominant, context);
2577         return builder.build();
2578     }
2579 
2580     protected void mergeActivationFile(ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context) {
2581         mergeActivationFile_Missing(builder, target, source, sourceDominant, context);
2582         mergeActivationFile_Exists(builder, target, source, sourceDominant, context);
2583     }
2584 
2585     protected void mergeActivationFile_Missing(ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context) {
2586         String src = source.getMissing();
2587         String tgt = target.getMissing();
2588         if (src != null && (sourceDominant || tgt == null)) {
2589             builder.missing(src);
2590             builder.location("missing", source.getLocation("missing"));
2591         }
2592     }
2593     protected void mergeActivationFile_Exists(ActivationFile.Builder builder, ActivationFile target, ActivationFile source, boolean sourceDominant, Map<Object, Object> context) {
2594         String src = source.getExists();
2595         String tgt = target.getExists();
2596         if (src != null && (sourceDominant || tgt == null)) {
2597             builder.exists(src);
2598             builder.location("exists", source.getLocation("exists"));
2599         }
2600     }
2601 
2602     protected ReportPlugin mergeReportPlugin(ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2603         ReportPlugin.Builder builder = ReportPlugin.newBuilder(target);
2604         mergeReportPlugin(builder, target, source, sourceDominant, context);
2605         return builder.build();
2606     }
2607 
2608     protected void mergeReportPlugin(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2609         mergeConfigurationContainer(builder, target, source, sourceDominant, context);
2610         mergeReportPlugin_GroupId(builder, target, source, sourceDominant, context);
2611         mergeReportPlugin_ArtifactId(builder, target, source, sourceDominant, context);
2612         mergeReportPlugin_Version(builder, target, source, sourceDominant, context);
2613         mergeReportPlugin_ReportSets(builder, target, source, sourceDominant, context);
2614     }
2615 
2616     protected void mergeReportPlugin_Inherited(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2617         String src = source.getInherited();
2618         String tgt = target.getInherited();
2619         if (src != null && (sourceDominant || tgt == null)) {
2620             builder.inherited(src);
2621             builder.location("inherited", source.getLocation("inherited"));
2622         }
2623     }
2624     protected void mergeReportPlugin_Configuration(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2625         XmlNode src = source.getConfiguration();
2626         if (src != null) {
2627             XmlNode tgt = target.getConfiguration();
2628             if (tgt == null) {
2629                 builder.configuration(src);
2630                 builder.location("configuration", source.getLocation("configuration"));
2631             } else if (sourceDominant) {
2632                 builder.configuration(src.merge(tgt));
2633                 builder.location("configuration", target.getLocation("configuration"));
2634             } else {
2635                 builder.configuration(tgt.merge(src));
2636                 builder.location("configuration", null);
2637             }
2638         }
2639     }
2640     protected void mergeReportPlugin_GroupId(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2641         String src = source.getGroupId();
2642         String tgt = target.getGroupId();
2643         if (src != null && (sourceDominant || tgt == null)) {
2644             builder.groupId(src);
2645             builder.location("groupId", source.getLocation("groupId"));
2646         }
2647     }
2648     protected void mergeReportPlugin_ArtifactId(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2649         String src = source.getArtifactId();
2650         String tgt = target.getArtifactId();
2651         if (src != null && (sourceDominant || tgt == null)) {
2652             builder.artifactId(src);
2653             builder.location("artifactId", source.getLocation("artifactId"));
2654         }
2655     }
2656     protected void mergeReportPlugin_Version(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2657         String src = source.getVersion();
2658         String tgt = target.getVersion();
2659         if (src != null && (sourceDominant || tgt == null)) {
2660             builder.version(src);
2661             builder.location("version", source.getLocation("version"));
2662         }
2663     }
2664     protected void mergeReportPlugin_ReportSets(ReportPlugin.Builder builder, ReportPlugin target, ReportPlugin source, boolean sourceDominant, Map<Object, Object> context) {
2665         if (deepMerge) {
2666             builder.reportSets(merge(target.getReportSets(), source.getReportSets(), getReportSetKey(),
2667                     (t, s) -> mergeReportSet(t, s, sourceDominant, context)));
2668         } else {
2669             builder.reportSets(merge(target.getReportSets(), source.getReportSets(), sourceDominant, getReportSetKey()));
2670         }
2671     }
2672 
2673     protected ReportSet mergeReportSet(ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2674         ReportSet.Builder builder = ReportSet.newBuilder(target);
2675         mergeReportSet(builder, target, source, sourceDominant, context);
2676         return builder.build();
2677     }
2678 
2679     protected void mergeReportSet(ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2680         mergeConfigurationContainer(builder, target, source, sourceDominant, context);
2681         mergeReportSet_Id(builder, target, source, sourceDominant, context);
2682         mergeReportSet_Reports(builder, target, source, sourceDominant, context);
2683     }
2684 
2685     protected void mergeReportSet_Inherited(ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2686         String src = source.getInherited();
2687         String tgt = target.getInherited();
2688         if (src != null && (sourceDominant || tgt == null)) {
2689             builder.inherited(src);
2690             builder.location("inherited", source.getLocation("inherited"));
2691         }
2692     }
2693     protected void mergeReportSet_Configuration(ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2694         XmlNode src = source.getConfiguration();
2695         if (src != null) {
2696             XmlNode tgt = target.getConfiguration();
2697             if (tgt == null) {
2698                 builder.configuration(src);
2699                 builder.location("configuration", source.getLocation("configuration"));
2700             } else if (sourceDominant) {
2701                 builder.configuration(src.merge(tgt));
2702                 builder.location("configuration", target.getLocation("configuration"));
2703             } else {
2704                 builder.configuration(tgt.merge(src));
2705                 builder.location("configuration", null);
2706             }
2707         }
2708     }
2709     protected void mergeReportSet_Id(ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2710         String src = source.getId();
2711         String tgt = target.getId();
2712         if (src != null && (sourceDominant || tgt == null)) {
2713             builder.id(src);
2714             builder.location("id", source.getLocation("id"));
2715         }
2716     }
2717     protected void mergeReportSet_Reports(ReportSet.Builder builder, ReportSet target, ReportSet source, boolean sourceDominant, Map<Object, Object> context) {
2718         builder.reports(merge(target.getReports(), source.getReports(), sourceDominant, e -> e));
2719     }
2720 
2721     protected Prerequisites mergePrerequisites(Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context) {
2722         Prerequisites.Builder builder = Prerequisites.newBuilder(target);
2723         mergePrerequisites(builder, target, source, sourceDominant, context);
2724         return builder.build();
2725     }
2726 
2727     protected void mergePrerequisites(Prerequisites.Builder builder, Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context) {
2728         mergePrerequisites_Maven(builder, target, source, sourceDominant, context);
2729     }
2730 
2731     protected void mergePrerequisites_Maven(Prerequisites.Builder builder, Prerequisites target, Prerequisites source, boolean sourceDominant, Map<Object, Object> context) {
2732         String src = source.getMaven();
2733         String tgt = target.getMaven();
2734         if (src != null && (sourceDominant || tgt == null)) {
2735             builder.maven(src);
2736             builder.location("maven", source.getLocation("maven"));
2737         }
2738     }
2739 
2740     protected Relocation mergeRelocation(Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2741         Relocation.Builder builder = Relocation.newBuilder(target);
2742         mergeRelocation(builder, target, source, sourceDominant, context);
2743         return builder.build();
2744     }
2745 
2746     protected void mergeRelocation(Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2747         mergeRelocation_GroupId(builder, target, source, sourceDominant, context);
2748         mergeRelocation_ArtifactId(builder, target, source, sourceDominant, context);
2749         mergeRelocation_Version(builder, target, source, sourceDominant, context);
2750         mergeRelocation_Message(builder, target, source, sourceDominant, context);
2751     }
2752 
2753     protected void mergeRelocation_GroupId(Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2754         String src = source.getGroupId();
2755         String tgt = target.getGroupId();
2756         if (src != null && (sourceDominant || tgt == null)) {
2757             builder.groupId(src);
2758             builder.location("groupId", source.getLocation("groupId"));
2759         }
2760     }
2761     protected void mergeRelocation_ArtifactId(Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2762         String src = source.getArtifactId();
2763         String tgt = target.getArtifactId();
2764         if (src != null && (sourceDominant || tgt == null)) {
2765             builder.artifactId(src);
2766             builder.location("artifactId", source.getLocation("artifactId"));
2767         }
2768     }
2769     protected void mergeRelocation_Version(Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2770         String src = source.getVersion();
2771         String tgt = target.getVersion();
2772         if (src != null && (sourceDominant || tgt == null)) {
2773             builder.version(src);
2774             builder.location("version", source.getLocation("version"));
2775         }
2776     }
2777     protected void mergeRelocation_Message(Relocation.Builder builder, Relocation target, Relocation source, boolean sourceDominant, Map<Object, Object> context) {
2778         String src = source.getMessage();
2779         String tgt = target.getMessage();
2780         if (src != null && (sourceDominant || tgt == null)) {
2781             builder.message(src);
2782             builder.location("message", source.getLocation("message"));
2783         }
2784     }
2785 
2786     protected Extension mergeExtension(Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2787         Extension.Builder builder = Extension.newBuilder(target);
2788         mergeExtension(builder, target, source, sourceDominant, context);
2789         return builder.build();
2790     }
2791 
2792     protected void mergeExtension(Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2793         mergeExtension_GroupId(builder, target, source, sourceDominant, context);
2794         mergeExtension_ArtifactId(builder, target, source, sourceDominant, context);
2795         mergeExtension_Version(builder, target, source, sourceDominant, context);
2796         mergeExtension_Configuration(builder, target, source, sourceDominant, context);
2797     }
2798 
2799     protected void mergeExtension_GroupId(Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2800         String src = source.getGroupId();
2801         String tgt = target.getGroupId();
2802         if (src != null && (sourceDominant || tgt == null)) {
2803             builder.groupId(src);
2804             builder.location("groupId", source.getLocation("groupId"));
2805         }
2806     }
2807     protected void mergeExtension_ArtifactId(Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2808         String src = source.getArtifactId();
2809         String tgt = target.getArtifactId();
2810         if (src != null && (sourceDominant || tgt == null)) {
2811             builder.artifactId(src);
2812             builder.location("artifactId", source.getLocation("artifactId"));
2813         }
2814     }
2815     protected void mergeExtension_Version(Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2816         String src = source.getVersion();
2817         String tgt = target.getVersion();
2818         if (src != null && (sourceDominant || tgt == null)) {
2819             builder.version(src);
2820             builder.location("version", source.getLocation("version"));
2821         }
2822     }
2823     protected void mergeExtension_Configuration(Extension.Builder builder, Extension target, Extension source, boolean sourceDominant, Map<Object, Object> context) {
2824         XmlNode src = source.getConfiguration();
2825         if (src != null) {
2826             XmlNode tgt = target.getConfiguration();
2827             if (tgt == null) {
2828                 builder.configuration(src);
2829                 builder.location("configuration", source.getLocation("configuration"));
2830             } else if (sourceDominant) {
2831                 builder.configuration(src.merge(tgt));
2832                 builder.location("configuration", target.getLocation("configuration"));
2833             } else {
2834                 builder.configuration(tgt.merge(src));
2835                 builder.location("configuration", null);
2836             }
2837         }
2838     }
2839 
2840 
2841     protected KeyComputer<Model> getModelKey() {
2842         return v -> v;
2843     }
2844     protected KeyComputer<ModelBase> getModelBaseKey() {
2845         return v -> v;
2846     }
2847     protected KeyComputer<PluginContainer> getPluginContainerKey() {
2848         return v -> v;
2849     }
2850     protected KeyComputer<PluginConfiguration> getPluginConfigurationKey() {
2851         return v -> v;
2852     }
2853     protected KeyComputer<BuildBase> getBuildBaseKey() {
2854         return v -> v;
2855     }
2856     protected KeyComputer<Build> getBuildKey() {
2857         return v -> v;
2858     }
2859     protected KeyComputer<CiManagement> getCiManagementKey() {
2860         return v -> v;
2861     }
2862     protected KeyComputer<Notifier> getNotifierKey() {
2863         return v -> v;
2864     }
2865     protected KeyComputer<Contributor> getContributorKey() {
2866         return v -> v;
2867     }
2868     protected KeyComputer<Dependency> getDependencyKey() {
2869         return v -> v;
2870     }
2871     protected KeyComputer<Developer> getDeveloperKey() {
2872         return v -> v;
2873     }
2874     protected KeyComputer<Exclusion> getExclusionKey() {
2875         return v -> v;
2876     }
2877     protected KeyComputer<IssueManagement> getIssueManagementKey() {
2878         return v -> v;
2879     }
2880     protected KeyComputer<DistributionManagement> getDistributionManagementKey() {
2881         return v -> v;
2882     }
2883     protected KeyComputer<License> getLicenseKey() {
2884         return v -> v;
2885     }
2886     protected KeyComputer<MailingList> getMailingListKey() {
2887         return v -> v;
2888     }
2889     protected KeyComputer<Organization> getOrganizationKey() {
2890         return v -> v;
2891     }
2892     protected KeyComputer<PatternSet> getPatternSetKey() {
2893         return v -> v;
2894     }
2895     protected KeyComputer<Parent> getParentKey() {
2896         return v -> v;
2897     }
2898     protected KeyComputer<Scm> getScmKey() {
2899         return v -> v;
2900     }
2901     protected KeyComputer<FileSet> getFileSetKey() {
2902         return v -> v;
2903     }
2904     protected KeyComputer<Resource> getResourceKey() {
2905         return v -> v;
2906     }
2907     protected KeyComputer<RepositoryBase> getRepositoryBaseKey() {
2908         return v -> v;
2909     }
2910     protected KeyComputer<Repository> getRepositoryKey() {
2911         return v -> v;
2912     }
2913     protected KeyComputer<DeploymentRepository> getDeploymentRepositoryKey() {
2914         return v -> v;
2915     }
2916     protected KeyComputer<RepositoryPolicy> getRepositoryPolicyKey() {
2917         return v -> v;
2918     }
2919     protected KeyComputer<Site> getSiteKey() {
2920         return v -> v;
2921     }
2922     protected KeyComputer<ConfigurationContainer> getConfigurationContainerKey() {
2923         return v -> v;
2924     }
2925     protected KeyComputer<Plugin> getPluginKey() {
2926         return v -> v;
2927     }
2928     protected KeyComputer<PluginExecution> getPluginExecutionKey() {
2929         return v -> v;
2930     }
2931     protected KeyComputer<DependencyManagement> getDependencyManagementKey() {
2932         return v -> v;
2933     }
2934     protected KeyComputer<PluginManagement> getPluginManagementKey() {
2935         return v -> v;
2936     }
2937     protected KeyComputer<Reporting> getReportingKey() {
2938         return v -> v;
2939     }
2940     protected KeyComputer<Profile> getProfileKey() {
2941         return v -> v;
2942     }
2943     protected KeyComputer<Activation> getActivationKey() {
2944         return v -> v;
2945     }
2946     protected KeyComputer<ActivationProperty> getActivationPropertyKey() {
2947         return v -> v;
2948     }
2949     protected KeyComputer<ActivationOS> getActivationOSKey() {
2950         return v -> v;
2951     }
2952     protected KeyComputer<ActivationFile> getActivationFileKey() {
2953         return v -> v;
2954     }
2955     protected KeyComputer<ReportPlugin> getReportPluginKey() {
2956         return v -> v;
2957     }
2958     protected KeyComputer<ReportSet> getReportSetKey() {
2959         return v -> v;
2960     }
2961     protected KeyComputer<Prerequisites> getPrerequisitesKey() {
2962         return v -> v;
2963     }
2964     protected KeyComputer<Relocation> getRelocationKey() {
2965         return v -> v;
2966     }
2967     protected KeyComputer<Extension> getExtensionKey() {
2968         return v -> v;
2969     }
2970 
2971     /**
2972      * Use to compute keys for data structures
2973      * @param <T> the data structure type
2974      */
2975     @FunctionalInterface
2976     public interface KeyComputer<T> extends Function<T, Object> {
2977     }
2978 
2979     /**
2980      * Merge two lists
2981      */
2982     public static <T> List<T> merge(List<T> tgt, List<T> src, boolean sourceDominant, KeyComputer<T> computer) {
2983         return merge(tgt, src, computer, (t, s) -> sourceDominant ? s : t);
2984     }
2985 
2986     public static <T> List<T> merge(List<T> tgt, List<T> src, KeyComputer<T> computer, BinaryOperator<T> remapping) {
2987         if (src.isEmpty()) {
2988             return tgt;
2989         }
2990 
2991         MergingList<T> list;
2992         if (tgt instanceof MergingList) {
2993             list = (MergingList<T>) tgt;
2994         } else {
2995             list = new MergingList<>(computer, src.size() + tgt.size());
2996             list.mergeAll(tgt, (t, s) -> s);
2997         }
2998 
2999         list.mergeAll(src, remapping);
3000         return list;
3001     }
3002 
3003     /**
3004      * Merging list
3005      * @param <V>
3006      */
3007     private static class MergingList<V> extends AbstractList<V> implements java.io.Serializable {
3008 
3009         private final KeyComputer<V> keyComputer;
3010         private Map<Object, V> map;
3011         private List<V> list;
3012 
3013         MergingList(KeyComputer<V> keyComputer, int initialCapacity) {
3014             this.map = new LinkedHashMap<>(initialCapacity);
3015             this.keyComputer = keyComputer;
3016         }
3017 
3018         Object writeReplace() throws ObjectStreamException {
3019             return new ArrayList<>(this);
3020         }
3021 
3022         @Override
3023         public Iterator<V> iterator() {
3024             if (map != null) {
3025                 return map.values().iterator();
3026             } else {
3027                 return list.iterator();
3028             }
3029         }
3030 
3031         void mergeAll(Collection<V> vs, BinaryOperator<V> remapping) {
3032             if (map == null) {
3033                 map = list.stream().collect(Collectors.toMap(keyComputer,
3034                     Function.identity(),
3035                     null,
3036                     LinkedHashMap::new));
3037                 list = null;
3038             }
3039 
3040             if (vs instanceof MergingList && ((MergingList<V>) vs).map != null) {
3041                 for (Map.Entry<Object, V> e : ((MergingList<V>) vs).map.entrySet()) {
3042                     Object key = e.getKey();
3043                     V v = e.getValue();
3044                     map.merge(key, v, remapping);
3045                 }
3046             } else {
3047                 for (V v : vs) {
3048                     Object key = keyComputer.apply(v);
3049                     map.merge(key, v, remapping);
3050                 }
3051             }
3052         }
3053 
3054         @Override
3055         public boolean contains(Object o) {
3056             if (map != null) {
3057                 return map.containsValue(o);
3058             } else {
3059                 return list.contains(o);
3060             }
3061         }
3062 
3063         private List<V> asList() {
3064             if (list == null) {
3065                 list = new ArrayList<>(map.values());
3066                 map = null;
3067             }
3068             return list;
3069         }
3070 
3071         @Override
3072         public void add(int index, V element) {
3073             asList().add(index, element);
3074         }
3075 
3076         @Override
3077         public V remove(int index) {
3078             return asList().remove(index);
3079         }
3080 
3081         @Override
3082         public V get(int index) {
3083             return asList().get(index);
3084         }
3085 
3086         @Override
3087         public int size() {
3088             if (map != null) {
3089                 return map.size();
3090             } else {
3091                 return list.size();
3092             }
3093         }
3094     }
3095 }