Skip to content

Commit 1cbf6ff

Browse files
committed
Sync with underscore-java.
1 parent a650f58 commit 1cbf6ff

File tree

8 files changed

+257
-116
lines changed

8 files changed

+257
-116
lines changed

.github/workflows/maven.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ jobs:
66
build:
77

88
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
java: [11, 16]
912

1013
steps:
1114
- uses: actions/checkout@v2
12-
- name: Set up JDK 11
15+
- name: Set up JDK ${{ matrix.java }}
1316
uses: actions/setup-java@v1
1417
with:
15-
java-version: 11
18+
java-version: ${{ matrix.java }}
1619
- name: Build with Maven
1720
run: mvn test jacoco:report --file pom.xml -B
1821

pom.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@
6363
<plugin>
6464
<groupId>org.apache.maven.plugins</groupId>
6565
<artifactId>maven-jar-plugin</artifactId>
66-
<version>3.0.2</version>
66+
<version>3.2.0</version>
6767
<configuration>
6868
<archive>
69-
<manifest>
70-
<mainClass>com.github.underscore.U</mainClass>
71-
</manifest>
69+
<manifestEntries>
70+
<Automatic-Module-Name>com.github.underscore</Automatic-Module-Name>
71+
<mainClass>com.github.underscore.U</mainClass>
72+
</manifestEntries>
7273
</archive>
7374
</configuration>
7475
</plugin>
@@ -106,7 +107,7 @@
106107
<plugin>
107108
<groupId>org.jacoco</groupId>
108109
<artifactId>jacoco-maven-plugin</artifactId>
109-
<version>0.8.5</version>
110+
<version>0.8.7</version>
110111
<executions>
111112
<execution>
112113
<id>prepare-agent</id>
@@ -125,12 +126,12 @@
125126
<plugin>
126127
<groupId>org.apache.maven.plugins</groupId>
127128
<artifactId>maven-project-info-reports-plugin</artifactId>
128-
<version>2.9</version>
129+
<version>3.1.2</version>
129130
</plugin>
130131
<plugin>
131132
<groupId>org.apache.maven.plugins</groupId>
132133
<artifactId>maven-site-plugin</artifactId>
133-
<version>3.7.1</version>
134+
<version>3.9.1</version>
134135
</plugin>
135136
</plugins>
136137
</build>
@@ -139,7 +140,7 @@
139140
<plugin>
140141
<groupId>org.jacoco</groupId>
141142
<artifactId>jacoco-maven-plugin</artifactId>
142-
<version>0.8.5</version>
143+
<version>0.8.7</version>
143144
<configuration>
144145
<excludes>
145146
<exclude>**/U$BaseHttpSslSocketFactory*.class</exclude>
@@ -150,12 +151,12 @@
150151
<plugin>
151152
<groupId>org.apache.maven.plugins</groupId>
152153
<artifactId>maven-surefire-report-plugin</artifactId>
153-
<version>2.22.0</version>
154+
<version>2.18</version>
154155
</plugin>
155156
<plugin>
156157
<groupId>org.apache.maven.plugins</groupId>
157158
<artifactId>maven-jxr-plugin</artifactId>
158-
<version>2.5</version>
159+
<version>3.1.1</version>
159160
</plugin>
160161
<plugin>
161162
<groupId>org.apache.maven.plugins</groupId>
@@ -169,7 +170,7 @@
169170
<plugin>
170171
<groupId>org.apache.maven.plugins</groupId>
171172
<artifactId>maven-pmd-plugin</artifactId>
172-
<version>3.5</version>
173+
<version>3.14.0</version>
173174
<configuration>
174175
<targetJdk>1.8</targetJdk>
175176
<rulesets>
@@ -204,15 +205,15 @@
204205
<dependency>
205206
<groupId>junit</groupId>
206207
<artifactId>junit</artifactId>
207-
<version>4.13.1</version>
208+
<version>4.13.2</version>
208209
<scope>test</scope>
209210
</dependency>
210211
<dependency>
211212
<groupId>org.awaitility</groupId>
212213
<artifactId>awaitility</artifactId>
213-
<version>4.0.3</version>
214+
<version>4.1.0</version>
214215
<scope>test</scope>
215216
</dependency>
216217
</dependencies>
217-
218+
218219
</project>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.function.Supplier;
77

88
public final class Optional<T> {
9-
private static final Optional<?> EMPTY = new Optional();
9+
private static final Optional<?> EMPTY = new Optional<>();
1010
private final T arg;
1111
private final boolean absent;
1212

@@ -99,7 +99,7 @@ public boolean equals(final Object o) {
9999
return false;
100100
}
101101

102-
final Optional optional = (Optional) o;
102+
final Optional<?> optional = (Optional) o;
103103

104104
return absent == optional.absent && Objects.equals(arg, optional.arg);
105105
}

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,8 +2537,8 @@ public static String escape(final String value) {
25372537
}
25382538

25392539
public static String unescape(final String value) {
2540-
return value.replaceAll("&#x60;", "`").replaceAll("&#x27;", "'").replaceAll("&lt;", "<")
2541-
.replaceAll("&gt;", ">").replaceAll("&quot;", "\"").replaceAll("&amp;", "&");
2540+
return value.replace("&#x60;", "`").replace("&#x27;", "'").replace("&lt;", "<")
2541+
.replace("&gt;", ">").replace("&quot;", "\"").replace("&amp;", "&");
25422542
}
25432543

25442544
/*
@@ -2892,8 +2892,7 @@ public Chain<T> tap(final Consumer<T> func) {
28922892
}
28932893

28942894
public Chain<T> forEach(final Consumer<T> func) {
2895-
U.each(list, func);
2896-
return new Chain<>(list);
2895+
return tap(func);
28972896
}
28982897

28992898
public Chain<T> forEachRight(final Consumer<T> func) {
@@ -3180,9 +3179,7 @@ public String join() {
31803179
@SuppressWarnings("unchecked")
31813180
public static <T> List<T> push(final List<T> list, final T ... values) {
31823181
final List<T> result = newArrayList(list);
3183-
for (T value : values) {
3184-
result.add(value);
3185-
}
3182+
Collections.addAll(result, values);
31863183
return result;
31873184
}
31883185

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
public final class Json {
3232
private static final String NULL = "null";
33+
private static final String DIGIT = "digit";
3334

3435
public static class JsonStringBuilder {
3536
public enum Step {
@@ -689,7 +690,7 @@ private Number readNumber() {
689690
readChar('-');
690691
int firstDigit = current;
691692
if (!readDigit()) {
692-
throw expected("digit");
693+
throw expected(DIGIT);
693694
}
694695
if (firstDigit != '0') {
695696
while (readDigit()) {
@@ -722,7 +723,7 @@ private boolean readFraction() {
722723
return false;
723724
}
724725
if (!readDigit()) {
725-
throw expected("digit");
726+
throw expected(DIGIT);
726727
}
727728
while (readDigit()) {
728729
}
@@ -737,7 +738,7 @@ private boolean readExponent() {
737738
readChar('-');
738739
}
739740
if (!readDigit()) {
740-
throw expected("digit");
741+
throw expected(DIGIT);
741742
}
742743
while (readDigit()) {
743744
}

0 commit comments

Comments
 (0)