Skip to content

Commit 5d7ce47

Browse files
committed
Revert "Improved format"
This reverts commit 4ea02a8.
1 parent 4ea02a8 commit 5d7ce47

12 files changed

Lines changed: 94 additions & 110 deletions

File tree

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

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
*/
2424
package com.github.underscore;
2525

26-
import org.w3c.dom.NodeList;
27-
2826
import java.io.FileInputStream;
2927
import java.io.FileOutputStream;
3028
import java.io.IOException;
@@ -65,10 +63,10 @@
6563
import java.util.function.Function;
6664
import java.util.function.Predicate;
6765
import java.util.zip.GZIPInputStream;
68-
6966
import javax.xml.xpath.XPath;
7067
import javax.xml.xpath.XPathConstants;
7168
import javax.xml.xpath.XPathFactory;
69+
import org.w3c.dom.NodeList;
7270

7371
@SuppressWarnings({
7472
"java:S135",
@@ -2861,25 +2859,21 @@ public static void jsonFolderToXml(
28612859
throws IOException {
28622860
Path sourceRoot = Paths.get(jsonFolder);
28632861
Path targetRoot = Paths.get(xmlFolder);
2864-
Files.walkFileTree(
2865-
sourceRoot,
2866-
new SimpleFileVisitor<>() {
2867-
@Override
2868-
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
2869-
throws IOException {
2870-
covertJsonToXml(path, sourceRoot, targetRoot, identStep);
2871-
return FileVisitResult.CONTINUE;
2872-
}
2873-
});
2862+
Files.walkFileTree(sourceRoot, new SimpleFileVisitor<>() {
2863+
@Override
2864+
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
2865+
covertJsonToXml(path, sourceRoot, targetRoot, identStep);
2866+
return FileVisitResult.CONTINUE;
2867+
}
2868+
});
28742869
}
28752870

28762871
public static void jsonFolderToXml(String jsonFolder, String xmlFolder) throws IOException {
28772872
jsonFolderToXml(jsonFolder, xmlFolder, Xml.XmlStringBuilder.Step.TWO_SPACES);
28782873
}
28792874

2880-
public static void covertJsonToXml(
2881-
Path path, Path sourceRoot, Path targetRoot, Xml.XmlStringBuilder.Step identStep)
2882-
throws IOException {
2875+
public static void covertJsonToXml(Path path, Path sourceRoot, Path targetRoot,
2876+
Xml.XmlStringBuilder.Step identStep) throws IOException {
28832877
Path relativePath = sourceRoot.relativize(path);
28842878
String fileName = relativePath.getFileName().toString();
28852879
String xmlFileName;
@@ -2898,25 +2892,21 @@ public static void xmlFolderToJson(
28982892
throws IOException {
28992893
Path sourceRoot = Paths.get(xmlFolder);
29002894
Path targetRoot = Paths.get(jsonFolder);
2901-
Files.walkFileTree(
2902-
sourceRoot,
2903-
new SimpleFileVisitor<>() {
2904-
@Override
2905-
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
2906-
throws IOException {
2907-
covertXmlToJson(path, sourceRoot, targetRoot, identStep);
2908-
return FileVisitResult.CONTINUE;
2909-
}
2910-
});
2895+
Files.walkFileTree(sourceRoot, new SimpleFileVisitor<>() {
2896+
@Override
2897+
public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
2898+
covertXmlToJson(path, sourceRoot, targetRoot, identStep);
2899+
return FileVisitResult.CONTINUE;
2900+
}
2901+
});
29112902
}
29122903

29132904
public static void xmlFolderToJson(String xmlFolder, String jsonFolder) throws IOException {
29142905
xmlFolderToJson(xmlFolder, jsonFolder, Json.JsonStringBuilder.Step.TWO_SPACES);
29152906
}
29162907

2917-
public static void covertXmlToJson(
2918-
Path path, Path sourceRoot, Path targetRoot, Json.JsonStringBuilder.Step identStep)
2919-
throws IOException {
2908+
public static void covertXmlToJson(Path path, Path sourceRoot, Path targetRoot,
2909+
Json.JsonStringBuilder.Step identStep) throws IOException {
29202910
Path relativePath = sourceRoot.relativize(path);
29212911
String fileName = relativePath.getFileName().toString();
29222912
String xmlFileName;
@@ -2994,11 +2984,11 @@ public static String detectEncoding(byte[] buffer) {
29942984
case 0x3C000000:
29952985
encoding = "UTF_32LE";
29962986
break;
2997-
// <?
2987+
// <?
29982988
case 0x3C003F00:
29992989
encoding = "UnicodeLittleUnmarked";
30002990
break;
3001-
// <?xm
2991+
// <?xm
30022992
case 0x3C3F786D:
30032993
encoding = "UTF8";
30042994
break;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,8 +1800,7 @@ protected static class Document {
18001800
private Document() {}
18011801

18021802
public static org.w3c.dom.Document createDocument(final String xml)
1803-
throws java.io.IOException,
1804-
javax.xml.parsers.ParserConfigurationException,
1803+
throws java.io.IOException, javax.xml.parsers.ParserConfigurationException,
18051804
org.xml.sax.SAXException {
18061805
final javax.xml.parsers.DocumentBuilderFactory factory =
18071806
javax.xml.parsers.DocumentBuilderFactory.newInstance();

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
*/
2424
package com.github.underscore;
2525

26+
import static java.util.Arrays.asList;
27+
import static java.util.Collections.singletonList;
2628
import static org.junit.jupiter.api.Assertions.assertEquals;
2729
import static org.junit.jupiter.api.Assertions.assertNull;
2830
import static org.junit.jupiter.api.Assertions.assertThrows;
2931

30-
import static java.util.Arrays.asList;
31-
import static java.util.Collections.singletonList;
32-
33-
import org.junit.jupiter.api.Test;
34-
3532
import java.util.ArrayList;
3633
import java.util.Arrays;
3734
import java.util.Collection;
@@ -41,6 +38,7 @@
4138
import java.util.Map;
4239
import java.util.NoSuchElementException;
4340
import java.util.Set;
41+
import org.junit.jupiter.api.Test;
4442

4543
/**
4644
* Underscore library unit test.
@@ -385,7 +383,8 @@ void interpose() {
385383
assertEquals("[a]", new Underscore<>(singletonList("a")).interpose("interpose").toString());
386384
assertEquals("[a, b]", new Underscore<>(singletonList("a, b")).interpose(null).toString());
387385
assertEquals("[a]", Underscore.chain(singletonList("a")).interpose("interpose").toString());
388-
assertEquals("[]", Underscore.chain(new ArrayList<>()).interpose("interpose").toString());
386+
assertEquals(
387+
"[]", Underscore.chain(new ArrayList<>()).interpose("interpose").toString());
389388
assertEquals(
390389
"[a, b, c]", Underscore.chain(asList("a", "b", "c")).interpose(null).toString());
391390
assertEquals(
@@ -651,7 +650,6 @@ void lastOrNull() {
651650
new Underscore<>(Collections.<Integer>emptyList())
652651
.lastOrNull(item -> item % 2 == 0));
653652
}
654-
655653
/*
656654
_.compact([0, 1, false, 2, '', 3]);
657655
=> [1, 2, 3]

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
*/
2424
package com.github.underscore;
2525

26-
import static org.junit.jupiter.api.Assertions.assertEquals;
27-
2826
import static java.util.Arrays.asList;
29-
30-
import org.junit.jupiter.api.Test;
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
3128

3229
import java.lang.reflect.Method;
3330
import java.util.ArrayList;
@@ -38,6 +35,7 @@
3835
import java.util.Set;
3936
import java.util.function.BiFunction;
4037
import java.util.function.Function;
38+
import org.junit.jupiter.api.Test;
4139

4240
/**
4341
* Underscore library unit test.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
*/
2424
package com.github.underscore;
2525

26+
import static java.util.Arrays.asList;
2627
import static org.junit.jupiter.api.Assertions.assertEquals;
2728
import static org.junit.jupiter.api.Assertions.assertFalse;
2829
import static org.junit.jupiter.api.Assertions.assertThrows;
2930
import static org.junit.jupiter.api.Assertions.assertTrue;
3031

31-
import static java.util.Arrays.asList;
32-
33-
import org.junit.jupiter.api.Test;
34-
3532
import java.io.Serializable;
3633
import java.util.ArrayDeque;
3734
import java.util.ArrayList;
@@ -45,6 +42,7 @@
4542
import java.util.Optional;
4643
import java.util.Set;
4744
import java.util.function.Function;
45+
import org.junit.jupiter.api.Test;
4846

4947
/**
5048
* Underscore library unit test.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
*/
2424
package com.github.underscore;
2525

26+
import static java.util.Arrays.asList;
2627
import static org.awaitility.Awaitility.await;
2728
import static org.junit.jupiter.api.Assertions.assertEquals;
2829
import static org.junit.jupiter.api.Assertions.assertTrue;
2930

30-
import static java.util.Arrays.asList;
31-
32-
import org.junit.jupiter.api.Test;
33-
3431
import java.util.ArrayList;
3532
import java.util.Arrays;
3633
import java.util.LinkedHashMap;
@@ -42,6 +39,7 @@
4239
import java.util.function.Predicate;
4340
import java.util.function.Supplier;
4441
import java.util.function.UnaryOperator;
42+
import org.junit.jupiter.api.Test;
4543

4644
@SuppressWarnings("java:S2925")
4745
class FunctionsTest {

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@
2323
*/
2424
package com.github.underscore;
2525

26+
import static java.util.Arrays.asList;
27+
import static java.util.Collections.singletonList;
2628
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
2729
import static org.junit.jupiter.api.Assertions.assertEquals;
2830
import static org.junit.jupiter.api.Assertions.assertNull;
2931
import static org.junit.jupiter.api.Assertions.assertThrows;
3032
import static org.junit.jupiter.api.Assertions.assertTrue;
3133

32-
import static java.util.Arrays.asList;
33-
import static java.util.Collections.singletonList;
34-
35-
import org.junit.jupiter.api.Test;
36-
3734
import java.io.IOException;
3835
import java.net.URISyntaxException;
3936
import java.nio.file.Files;
@@ -48,6 +45,7 @@
4845
import java.util.LinkedHashSet;
4946
import java.util.List;
5047
import java.util.Map;
48+
import org.junit.jupiter.api.Test;
5149

5250
/**
5351
* Underscore library unit test.
@@ -690,14 +688,13 @@ void fetchResponseBlob() {
690688
@Test
691689
void fetchGetHttps() {
692690
U.FetchResponse result =
693-
U.fetch(
694-
"https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json");
691+
U.fetch("https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json");
695692
assertEquals(
696693
"{\n"
697-
+ " \"fruit\": \"Apple\",\n"
698-
+ " \"size\": \"Large\",\n"
699-
+ " \"color\": \"Red\"\n"
700-
+ "}",
694+
+ " \"fruit\": \"Apple\",\n"
695+
+ " \"size\": \"Large\",\n"
696+
+ " \"color\": \"Red\"\n"
697+
+ "}",
701698
result.text());
702699
}
703700

@@ -2012,7 +2009,10 @@ void chainMap() {
20122009
.toString());
20132010
assertEquals(
20142011
"{name1=one, name2=two, 1=2}",
2015-
com.github.underscore.U.chain(
2012+
com.github
2013+
.underscore
2014+
.U
2015+
.chain(
20162016
new LinkedHashMap<>() {
20172017
{
20182018
put("name1", "one");
@@ -2024,7 +2024,10 @@ void chainMap() {
20242024
.toString());
20252025
assertEquals(
20262026
"{name1=one, name2=two, 1=2}",
2027-
com.github.underscore.U.of(
2027+
com.github
2028+
.underscore
2029+
.U
2030+
.of(
20282031
new LinkedHashMap<>() {
20292032
{
20302033
put("name1", "one");

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,19 @@
2323
*/
2424
package com.github.underscore;
2525

26+
import static java.util.Arrays.asList;
2627
import static org.junit.jupiter.api.Assertions.assertEquals;
2728
import static org.junit.jupiter.api.Assertions.assertNull;
2829
import static org.junit.jupiter.api.Assertions.assertThrows;
2930

30-
import static java.util.Arrays.asList;
31-
32-
import org.junit.jupiter.api.Test;
33-
3431
import java.math.BigDecimal;
3532
import java.math.BigInteger;
3633
import java.util.ArrayList;
3734
import java.util.Collections;
3835
import java.util.HashSet;
3936
import java.util.List;
4037
import java.util.function.Function;
38+
import org.junit.jupiter.api.Test;
4139

4240
/**
4341
* Underscore library unit test.
@@ -224,7 +222,8 @@ void sum() {
224222
assertEquals("14.2", result12.toString());
225223
final Integer result13 = U.sum(asList(-1, -2, -3));
226224
assertEquals("-6", result13.toString());
227-
final Integer resultChain = (Integer) U.chain(asList(1, 2, 3)).sum().item();
225+
final Integer resultChain =
226+
(Integer) U.chain(asList(1, 2, 3)).sum().item();
228227
assertEquals("6", resultChain.toString());
229228
final Integer result14 = U.sum(new Integer[] {1, 2, 3});
230229
assertEquals("6", result14.toString());
@@ -250,7 +249,8 @@ void sum() {
250249
assertEquals("6", result20.toString());
251250
final Integer result21 = U.sum(new Integer[] {1, 2, null});
252251
assertEquals("3", result21.toString());
253-
final Integer resultChainFunc = U.chain(asList(1, 2, 3)).sum(item -> item * 2).item();
252+
final Integer resultChainFunc =
253+
U.chain(asList(1, 2, 3)).sum(item -> item * 2).item();
254254
assertEquals("12", resultChainFunc.toString());
255255
final Number resultObj = new U(asList(1, 2, 3)).sum();
256256
assertEquals("6", resultObj.toString());
@@ -350,7 +350,8 @@ void mean() {
350350
assertEquals("0.5", result.toString());
351351
final Double resultObj = new U(asList((double) 0, 0.5, (double) 1)).mean();
352352
assertEquals("0.5", resultObj.toString());
353-
final Double resultChain = U.chain(asList((double) 0, 0.5, (double) 1)).mean().item();
353+
final Double resultChain =
354+
U.chain(asList((double) 0, 0.5, (double) 1)).mean().item();
354355
assertEquals("0.5", resultChain.toString());
355356
final Double result2 = U.mean(asList((long) 0, (long) 1, (long) 2));
356357
assertEquals("1.0", result2.toString());
@@ -373,15 +374,18 @@ void mean() {
373374
void median() {
374375
final Double result = U.median(asList(0, 0, 0, 0, 5));
375376
assertEquals("0.0", result.toString());
376-
final Double resultObj = new U<>(asList(0, 0, 0, 0, 5)).median();
377+
final Double resultObj =
378+
new U<>(asList(0, 0, 0, 0, 5)).median();
377379
assertEquals("0.0", resultObj.toString());
378-
final Double resultChain = U.chain(asList(0, 0, 0, 0, 5)).median().item();
380+
final Double resultChain =
381+
U.chain(asList(0, 0, 0, 0, 5)).median().item();
379382
assertEquals("0.0", resultChain.toString());
380383
final Double result2 = U.median(asList(0, 0, 1, 2, 5));
381384
assertEquals("1.0", result2.toString());
382385
final Double result3 = U.median(asList(0, 0, 1, 2));
383386
assertEquals("0.5", result3.toString());
384-
final Double result4 = U.median(asList(0, 0, 1, 2, 3, 4));
387+
final Double result4 =
388+
U.median(asList(0, 0, 1, 2, 3, 4));
385389
assertEquals("1.5", result4.toString());
386390
}
387391

0 commit comments

Comments
 (0)