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