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