1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.xml;
20
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.maven.api.annotations.Experimental;
25 import org.apache.maven.api.annotations.Immutable;
26 import org.apache.maven.api.annotations.Nonnull;
27 import org.apache.maven.api.annotations.Nullable;
28 import org.apache.maven.api.annotations.ThreadSafe;
29
30
31
32
33
34
35 @Experimental
36 @ThreadSafe
37 @Immutable
38 public interface XmlNode {
39
40 String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children";
41
42 String CHILDREN_COMBINATION_MERGE = "merge";
43
44 String CHILDREN_COMBINATION_APPEND = "append";
45
46
47
48
49
50
51 String DEFAULT_CHILDREN_COMBINATION_MODE = CHILDREN_COMBINATION_MERGE;
52
53 String SELF_COMBINATION_MODE_ATTRIBUTE = "combine.self";
54
55 String SELF_COMBINATION_OVERRIDE = "override";
56
57 String SELF_COMBINATION_MERGE = "merge";
58
59 String SELF_COMBINATION_REMOVE = "remove";
60
61
62
63
64 String ID_COMBINATION_MODE_ATTRIBUTE = "combine.id";
65
66
67
68
69
70 String KEYS_COMBINATION_MODE_ATTRIBUTE = "combine.keys";
71
72
73
74
75
76
77
78 String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
79
80 @Nonnull
81 String getName();
82
83 @Nonnull
84 String getNamespaceUri();
85
86 @Nonnull
87 String getPrefix();
88
89 @Nullable
90 String getValue();
91
92 @Nonnull
93 Map<String, String> getAttributes();
94
95 @Nullable
96 String getAttribute(@Nonnull String name);
97
98 @Nonnull
99 List<XmlNode> getChildren();
100
101 @Nullable
102 XmlNode getChild(String name);
103
104 @Nullable
105 Object getInputLocation();
106
107 default XmlNode merge(@Nullable XmlNode source) {
108 return merge(source, (Boolean) null);
109 }
110
111 XmlNode merge(@Nullable XmlNode source, @Nullable Boolean childMergeOverride);
112
113
114
115
116
117
118
119
120
121
122 @Nullable
123 static XmlNode merge(@Nullable XmlNode dominant, @Nullable XmlNode recessive) {
124 return merge(dominant, recessive, null);
125 }
126
127 @Nullable
128 static XmlNode merge(
129 @Nullable XmlNode dominant, @Nullable XmlNode recessive, @Nullable Boolean childMergeOverride) {
130 if (recessive == null) {
131 return dominant;
132 }
133 if (dominant == null) {
134 return recessive;
135 }
136 return dominant.merge(recessive, childMergeOverride);
137 }
138 }