Skip to content

Commit 4839c26

Browse files
committed
Sync with underscore-java
1 parent 10178d8 commit 4839c26

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,11 +2005,7 @@ public byte[] blob() {
20052005
}
20062006

20072007
public String text() {
2008-
try {
2009-
return stream.toString(StandardCharsets.UTF_8.name());
2010-
} catch (java.io.UnsupportedEncodingException ex) {
2011-
throw new UnsupportedOperationException(ex);
2012-
}
2008+
return stream.toString(StandardCharsets.UTF_8);
20132009
}
20142010

20152011
public Object json() {
@@ -3330,7 +3326,7 @@ public Builder add(final String key, final Builder builder) {
33303326
}
33313327

33323328
public Builder add(final Map<String, Object> map) {
3333-
deepCopyMap(map).forEach(data::put);
3329+
data.putAll(deepCopyMap(map));
33343330
return this;
33353331
}
33363332

@@ -3361,7 +3357,7 @@ public static Builder fromXml(final String xml) {
33613357

33623358
public static Builder fromMap(final Map<String, Object> map) {
33633359
final Builder builder = new Builder();
3364-
deepCopyMap(map).forEach(builder.data::put);
3360+
builder.data.putAll(deepCopyMap(map));
33653361
return builder;
33663362
}
33673363

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ public XmlStringBuilder append(final String string) {
142142
}
143143

144144
public XmlStringBuilder fillSpaces() {
145-
for (int index = 0; index < ident; index += 1) {
146-
builder.append(identStep == Step.TABS ? '\t' : ' ');
147-
}
145+
builder.append(
146+
String.valueOf(identStep == Step.TABS ? '\t' : ' ').repeat(Math.max(0, ident)));
148147
return this;
149148
}
150149

@@ -1053,9 +1052,7 @@ private static void escape(String s, StringBuilder sb) {
10531052
|| ch >= '\u2000' && ch <= '\u20FF') {
10541053
String ss = Integer.toHexString(ch);
10551054
sb.append("&#x");
1056-
for (int k = 0; k < 4 - ss.length(); k++) {
1057-
sb.append('0');
1058-
}
1055+
sb.append("0".repeat(4 - ss.length()));
10591056
sb.append(ss.toUpperCase()).append(";");
10601057
} else {
10611058
sb.append(ch);

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -685,19 +685,6 @@ void fetchGetXml() {
685685
assertEquals("Tove", U.get(result.xmlMap(), "note.to"));
686686
}
687687

688-
@Test
689-
void fetchResponseError() {
690-
java.io.ByteArrayOutputStream stream =
691-
new java.io.ByteArrayOutputStream() {
692-
public String toString(String encoding)
693-
throws java.io.UnsupportedEncodingException {
694-
throw new java.io.UnsupportedEncodingException();
695-
}
696-
};
697-
U.FetchResponse fetchResponse = new U.FetchResponse(true, 100, null, stream);
698-
assertThrows(UnsupportedOperationException.class, () -> fetchResponse.text());
699-
}
700-
701688
@Test
702689
void fetchResponseBlob() {
703690
java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream();

0 commit comments

Comments
 (0)