Skip to content

Commit 7204878

Browse files
authored
Added XmlBuilder.build()
1 parent 5eec2c3 commit 7204878

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/main/java/com/github/underscore/XmlBuilder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ public XmlBuilder remove(final String key) {
123123
return this;
124124
}
125125

126+
public Map<String, Object> build() {
127+
return U.deepCopyMap(data);
128+
}
129+
126130
public XmlBuilder clear() {
127131
data.clear();
128132
return this;

src/test/java/com/github/underscore/XmlBuilderTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ void remove() {
132132
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root></root>", xmlBuilder.asString());
133133
}
134134

135+
@Test
136+
void build() {
137+
XmlBuilder xmlBuilder = new XmlBuilder("xml").e("123");
138+
assertEquals("{xml={123={-self-closing=true}}}", xmlBuilder.build().toString());
139+
}
140+
135141
@Test
136142
void clear() {
137143
XmlBuilder xmlBuilder = new XmlBuilder("xml").e("123");

0 commit comments

Comments
 (0)