Skip to content

Commit 5b5fe55

Browse files
committed
Add Builder.set(path, value).
1 parent 563ff14 commit 5b5fe55

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/github/underscore/lodash/U.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,11 @@ public Builder add(final Object value) {
22712271
return this;
22722272
}
22732273

2274+
public Builder set(final String path, final Object value) {
2275+
U.set(data, path, value);
2276+
return this;
2277+
}
2278+
22742279
public Builder add(final Builder builder) {
22752280
data.putAll(builder.data);
22762281
return this;

src/test/java/com/github/underscore/lodash/LodashTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ public void removeMinusesAndConvertNumbers() {
754754
assertEquals("{list=[[]]}", result10.toString());
755755
}
756756

757-
758757
@Test
759758
public void objectBuilder() {
760759
U.Builder builder = U.objectBuilder().add("1", "2").add("2");
@@ -763,7 +762,8 @@ public void objectBuilder() {
763762
U.Builder.fromJson("{}");
764763
builder.toXml();
765764
U.Builder.fromXml("<a/>");
766-
assertEquals("{1=2}", builder.build().toString());
765+
builder.set("1", "3");
766+
assertEquals("{1=3}", builder.build().toString());
767767
}
768768

769769
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)