Skip to content

Commit

Permalink
rewrite JSONArray forEach to for
Browse files Browse the repository at this point in the history
  • Loading branch information
kane50613 committed May 15, 2021
1 parent f14588d commit dc4e518
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tw.kane</groupId>
<artifactId>osu4j</artifactId>
<version>v1.1.3</version>
<version>v1.1.4</version>
<build>
<plugins>
<plugin>
Expand All @@ -23,7 +23,7 @@
<distributionManagement>
<repository>
<id>github</id>
<name>osu!4J - The osu API client written in Java</name>
<name>osu!4J - The osu API wrapper written in Java</name>
<url>https://maven.pkg.github.com/Gary50613/osu4j</url>
</repository>
</distributionManagement>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>tw.kane</groupId>
<artifactId>osu4j</artifactId>
<version>v1.1.3</version>
<version>v1.1.4</version>

<distributionManagement>
<repository>
<id>github</id>
<name>osu!4J - The osu API client written in Java</name>
<name>osu!4J - The osu API wrapper written in Java</name>
<url>https://maven.pkg.github.com/Gary50613/osu4j</url>
</repository>
</distributionManagement>
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/tw/kane/osu4j/OsuClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tw.kane.osu4j.Exception.NotFoundException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

Expand Down Expand Up @@ -75,10 +76,10 @@ public Score[] getUserRecent(String id) throws IOException, InvalidTokenExceptio
JSONArray resultArray = new JSONArray(responseString);
if(resultArray.length() == 0)
throw new NotFoundException();
List<Score> scores = new LinkedList<>();
resultArray.toList().forEach(score ->
scores.add(new Score((JSONObject) score))
);
List<Score> scores = new ArrayList<>();
for (int i = 0; i < resultArray.length(); i++) {
scores.add(new Score(resultArray.getJSONObject(i)));
}
return scores.toArray(scores.toArray(new Score[scores.size()]));
}
return null;
Expand Down Expand Up @@ -109,10 +110,10 @@ public Score[] getUserBest(String id) throws IOException, InvalidTokenException,
JSONArray resultArray = new JSONArray(responseString);
if(resultArray.length() == 0)
throw new NotFoundException();
List<Score> scores = new LinkedList<>();
resultArray.toList().forEach(score ->
scores.add(new Score((JSONObject) score))
);
List<Score> scores = new ArrayList<>();
for (int i = 0; i < resultArray.length(); i++) {
scores.add(new Score(resultArray.getJSONObject(i)));
}
return scores.toArray(scores.toArray(new Score[scores.size()]));
}
return null;
Expand Down

0 comments on commit dc4e518

Please sign in to comment.