From 08162ac2bb998b91a99a2c88ae8755402cbc693d Mon Sep 17 00:00:00 2001 From: Wyv <181348033+wyvrtn@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:02:48 +0000 Subject: [PATCH] style: Super Linter recommendations --- .../java/jospi/client/MultiApiClient.java | 4 +-- ...alBlockingStatefulHttpServiceProvider.java | 4 ++- .../java/jospi/endpoints/BeatmapPacks.java | 2 +- .../java/jospi/endpoints/BeatmapSets.java | 4 +-- src/main/java/jospi/endpoints/Beatmaps.java | 12 +++---- src/main/java/jospi/endpoints/Changelogs.java | 6 ++-- src/main/java/jospi/endpoints/Comments.java | 10 +++--- src/main/java/jospi/endpoints/Events.java | 4 +-- src/main/java/jospi/endpoints/Home.java | 2 +- src/main/java/jospi/endpoints/Matches.java | 4 +-- .../java/jospi/endpoints/Multiplayer.java | 6 ++-- src/main/java/jospi/endpoints/News.java | 2 +- src/main/java/jospi/endpoints/Rankings.java | 14 ++++++--- src/main/java/jospi/endpoints/Users.java | 20 ++++++------ src/main/java/jospi/endpoints/Wikis.java | 2 +- .../changelogs/ChangelogEntryCategory.java | 2 +- .../jospi/iterator/AsyncLazyEnumerable.java | 31 ++++++++++--------- src/main/java/jospi/iterator/ExitToken.java | 23 ++++---------- src/main/java/jospi/models/generic/Text.java | 2 +- .../java/jospi/models/home/SearchResult.java | 8 +++-- .../java/jospi/models/records/HttpRecord.java | 4 +-- .../jospi/models/users/GroupDescription.java | 4 +-- .../java/jospi/models/users/HighestRank.java | 2 +- src/main/java/jospi/models/users/Kudosu.java | 4 +-- 24 files changed, 90 insertions(+), 86 deletions(-) diff --git a/src/main/java/jospi/client/MultiApiClient.java b/src/main/java/jospi/client/MultiApiClient.java index 2b1d436..9b108ce 100644 --- a/src/main/java/jospi/client/MultiApiClient.java +++ b/src/main/java/jospi/client/MultiApiClient.java @@ -11,7 +11,7 @@ import lombok.experimental.Delegate; public final class MultiApiClient { - @Delegate(excludes=OsuApiClientDelgationExclusions.class) + @Delegate(excludes = OsuApiClientDelgationExclusions.class) private final OsuApiClient client; @Getter @@ -35,6 +35,6 @@ public void switchInstance(K key) { } private interface OsuApiClientDelgationExclusions { - public void updateAuthorization(AbstractApiAuthorization newAuth); + void updateAuthorization(AbstractApiAuthorization newAuth); } } diff --git a/src/main/java/jospi/client/core/OsuApiClientInternalBlockingStatefulHttpServiceProvider.java b/src/main/java/jospi/client/core/OsuApiClientInternalBlockingStatefulHttpServiceProvider.java index 74aea7c..51a18d4 100644 --- a/src/main/java/jospi/client/core/OsuApiClientInternalBlockingStatefulHttpServiceProvider.java +++ b/src/main/java/jospi/client/core/OsuApiClientInternalBlockingStatefulHttpServiceProvider.java @@ -91,7 +91,9 @@ private T simpleJsonRequest(HttpRequest request, TypeReference typeRefere private String buildUri(String... pathArgs) { StringBuilder sb = new StringBuilder(GATEWAY); - for (String arg : pathArgs) sb.append(arg); + for (String arg : pathArgs) { + sb.append(arg); + } return new String(sb); } diff --git a/src/main/java/jospi/endpoints/BeatmapPacks.java b/src/main/java/jospi/endpoints/BeatmapPacks.java index e725890..91297d4 100644 --- a/src/main/java/jospi/endpoints/BeatmapPacks.java +++ b/src/main/java/jospi/endpoints/BeatmapPacks.java @@ -42,6 +42,6 @@ public CompletableFuture getBeatmapPack(String tag) { } public CompletableFuture getBeatmapPack(String tag, boolean legacyOnly) { - return client.getJsonAsync(BASE + "packs/"+ tag + "?" + (legacyOnly? 1:0), BeatmapPack.class); + return client.getJsonAsync(BASE + "packs/" + tag + "?" + (legacyOnly ? 1 : 0), BeatmapPack.class); } } diff --git a/src/main/java/jospi/endpoints/BeatmapSets.java b/src/main/java/jospi/endpoints/BeatmapSets.java index f343d38..474be32 100644 --- a/src/main/java/jospi/endpoints/BeatmapSets.java +++ b/src/main/java/jospi/endpoints/BeatmapSets.java @@ -15,10 +15,10 @@ protected BeatmapSets(OsuApiClient client) { } public CompletableFuture lookupBeatmapSet(int beatmapId) { - return client.getJsonAsync(BASE+"lookup?beatmap_id="+beatmapId, BeatmapSetExtended.class); + return client.getJsonAsync(BASE + "lookup?beatmap_id=" + beatmapId, BeatmapSetExtended.class); } public CompletableFuture getBeatmapSet(int beatmapSetId) { - return client.getJsonAsync(BASE+beatmapSetId, BeatmapSetExtended.class); + return client.getJsonAsync(BASE + beatmapSetId, BeatmapSetExtended.class); } } diff --git a/src/main/java/jospi/endpoints/Beatmaps.java b/src/main/java/jospi/endpoints/Beatmaps.java index e36f606..bda12b0 100644 --- a/src/main/java/jospi/endpoints/Beatmaps.java +++ b/src/main/java/jospi/endpoints/Beatmaps.java @@ -41,11 +41,11 @@ public CompletableFuture lookupBeatmapId(String id) { } private CompletableFuture lookupBeatmapInternal(String query) { - return client.getJsonAsync(BASE+"lookup?" + query, Beatmap.class); + return client.getJsonAsync(BASE + "lookup?" + query, Beatmap.class); } public CompletableFuture getUserBeatmapScore(int beatmapId, int userId, Ruleset ruleset, String mods) { - return client.getJsonAsync(BASE+beatmapId+"/scores/users/" + return client.getJsonAsync(BASE + beatmapId + "/scores/users/" +userId, map -> { map.put("mode", ruleset); map.put("mods", mods); @@ -53,14 +53,14 @@ public CompletableFuture getUserBeatmapScore(int beatmapId, in } public CompletableFuture getUserBeatmapScores(int beatmapId, int userId, Ruleset ruleset) { - return client.getJsonAsync(BASE+beatmapId+"/scores/users/" + return client.getJsonAsync(BASE + beatmapId + "/scores/users/" +userId+"/all", map -> { map.put("map", ruleset); }, Score[].class); } public CompletableFuture getBeatmapScores(int beatmapId, Ruleset ruleset, String mods) { - return client.getJsonAsync(BASE+beatmapId+"/scores", map -> { + return client.getJsonAsync(BASE + beatmapId + "/scores", map -> { map.put("mode", ruleset); map.put("mods", mods); }, BeatmapScores.class); @@ -74,10 +74,10 @@ public CompletableFuture getBeatmaps(int[] ids) { } public CompletableFuture getBeatmap(int id) { - return client.getJsonAsync(BASE+id, BeatmapExtended.class); + return client.getJsonAsync(BASE + id, BeatmapExtended.class); } public CompletableFuture getDifficultyAttributes(int id) { - return client.getJsonAsync(BASE+id+"/attributes", HttpMethod.POST, DifficultyAttributes.class); + return client.getJsonAsync(BASE + id + "/attributes", HttpMethod.POST, DifficultyAttributes.class); } } diff --git a/src/main/java/jospi/endpoints/Changelogs.java b/src/main/java/jospi/endpoints/Changelogs.java index 1c64213..2a140e0 100644 --- a/src/main/java/jospi/endpoints/Changelogs.java +++ b/src/main/java/jospi/endpoints/Changelogs.java @@ -16,7 +16,7 @@ protected Changelogs(OsuApiClient client) { } public CompletableFuture getBuild(String stream, String build) { - return client.getJsonAsync(BASE+stream+"/"+build, Build.class); + return client.getJsonAsync(BASE + stream + "/" + build, Build.class); } public CompletableFuture getChangelogListing(String stream, String fromBuild, String toBuild, int maxBuildId) { @@ -29,10 +29,10 @@ public CompletableFuture getChangelogListing(String stream, St } public CompletableFuture lookupBuildId(int buildId) { - return client.getJsonAsync(BASE+buildId+"?key=id", Build.class); + return client.getJsonAsync(BASE + buildId + "?key=id", Build.class); } public CompletableFuture lookupLatestBuild(String stream) { - return client.getJsonAsync(BASE+stream, Build.class); + return client.getJsonAsync(BASE + stream, Build.class); } } diff --git a/src/main/java/jospi/endpoints/Comments.java b/src/main/java/jospi/endpoints/Comments.java index 8ab400d..2f68d44 100644 --- a/src/main/java/jospi/endpoints/Comments.java +++ b/src/main/java/jospi/endpoints/Comments.java @@ -23,7 +23,7 @@ protected Comments(OsuApiClient client) { } public CompletableFuture getComment(int commentId) { - return client.getJsonAsync(BASE+commentId, CommentBundle.class); + return client.getJsonAsync(BASE + commentId, CommentBundle.class); } public AsyncLazyEnumerable getComments(int after, CommentableType type, @@ -32,18 +32,18 @@ public AsyncLazyEnumerable getComments(int after, Comment Function, CompletableFuture> func = t -> CompletableFuture.supplyAsync(() -> { CommentBundle bundle = client.getJson(BASE, map -> { - map.put("cursor[id]", t.getToken().id==0? null : t.getToken().id); - map.put("cursor[created_at]", t.getToken().createdAt==null? null : t.getToken().createdAt); + map.put("cursor[id]", t.getToken().id == 0 ? null : t.getToken().id); + map.put("cursor[created_at]", t.getToken().createdAt == null ? null : t.getToken().createdAt); map.put("after", after); map.put("commentable_type", type); map.put("commentable_id", commentableId); map.put("parent_id", parentId); map.put("sort", sort); }, CommentBundle.class); - if (bundle==null) { + if (bundle == null) { throw new OsuApiException("An error occured while requesting the comment bundle. (bundle is null)"); } - token.setNext(bundle==null? null : bundle.getCursor()); + token.setNext(bundle == null ? null : bundle.getCursor()); return bundle; }); return new AsyncLazyEnumerable<>(func, token); diff --git a/src/main/java/jospi/endpoints/Events.java b/src/main/java/jospi/endpoints/Events.java index 472eae9..c644410 100644 --- a/src/main/java/jospi/endpoints/Events.java +++ b/src/main/java/jospi/endpoints/Events.java @@ -12,7 +12,7 @@ import jospi.models.events.Event; import jospi.models.generic.CursorResponse; -public class Events { +public final class Events { private static final String BASE = "/events/"; private final OsuApiClient client; @@ -32,7 +32,7 @@ public AsyncLazyEnumerable getEvents(PostSort sort) { CursorResponse events = client.getJson(BASE, map -> { map.put("sort", sort); map.put("cursor_string", token.getToken()); - }, new TypeReference>() {}); + }, new TypeReference>() { }); token.setNext(events.getCursorString()); return events.getData(); }); diff --git a/src/main/java/jospi/endpoints/Home.java b/src/main/java/jospi/endpoints/Home.java index c0fbded..a816ebb 100644 --- a/src/main/java/jospi/endpoints/Home.java +++ b/src/main/java/jospi/endpoints/Home.java @@ -10,7 +10,7 @@ import jospi.models.users.User; import jospi.models.wikis.WikiPage; -public class Home { +public final class Home { private static final String BASE = "/search/"; private final OsuApiClient client; diff --git a/src/main/java/jospi/endpoints/Matches.java b/src/main/java/jospi/endpoints/Matches.java index e77fd91..05a6c1c 100644 --- a/src/main/java/jospi/endpoints/Matches.java +++ b/src/main/java/jospi/endpoints/Matches.java @@ -11,7 +11,7 @@ import jospi.models.matches.MatchBundle; import jospi.models.matches.MatchesBundle; -public class Matches { +public final class Matches { private static final String BASE = "/matches/"; private final OsuApiClient client; @@ -35,7 +35,7 @@ public AsyncLazyEnumerable getMatches(int limit, MatchBundleSor } public CompletableFuture getMatch(int matchId, int before, int after, int limit) { - return client.getJsonAsync(BASE+matchId, map -> { + return client.getJsonAsync(BASE + matchId, map -> { map.put("before", before); map.put("after", after); map.put("limit", limit); diff --git a/src/main/java/jospi/endpoints/Multiplayer.java b/src/main/java/jospi/endpoints/Multiplayer.java index 36c9d23..06c1ddd 100644 --- a/src/main/java/jospi/endpoints/Multiplayer.java +++ b/src/main/java/jospi/endpoints/Multiplayer.java @@ -14,7 +14,7 @@ import jospi.iterator.ExitToken; import jospi.models.multiplayer.MultiplayerScores; -public class Multiplayer { +public final class Multiplayer { private static final String BASE = "/rooms/"; private final OsuApiClient client; @@ -27,7 +27,7 @@ public AsyncLazyEnumerable getMultiplayerScores(int r ExitToken token = new ExitToken<>(""); Function, CompletableFuture> func = tkn -> CompletableFuture.supplyAsync(() -> { - MultiplayerScores multiplayerScores = client.getJson(BASE+roomId+"/playlist/"+playlistId+"/scores", map -> { + MultiplayerScores multiplayerScores = client.getJson(BASE + roomId + "/playlist/" + playlistId + "/scores", map -> { map.put("limit", limit); map.put("sort", sort); map.put("cursor_string", tkn.getToken()); @@ -46,6 +46,6 @@ public CompletableFuture getRooms(int limit, MultiplayerRoomMode mode, St map.put("season_id", seasonId); map.put("sort", sort); map.put("type_group", typeGroup); - }, new TypeReference() {}); + }, new TypeReference() { }); } } diff --git a/src/main/java/jospi/endpoints/News.java b/src/main/java/jospi/endpoints/News.java index 94a1c64..0d89b0a 100644 --- a/src/main/java/jospi/endpoints/News.java +++ b/src/main/java/jospi/endpoints/News.java @@ -32,7 +32,7 @@ public AsyncLazyEnumerable getNewsPosts() { } public CompletableFuture getNewsPost(String slug) { - return client.getJsonAsync(BASE+slug, NewsPost.class); + return client.getJsonAsync(BASE + slug, NewsPost.class); } public CompletableFuture getNewsPost(int id) { diff --git a/src/main/java/jospi/endpoints/Rankings.java b/src/main/java/jospi/endpoints/Rankings.java index 3e53bb8..7c21026 100644 --- a/src/main/java/jospi/endpoints/Rankings.java +++ b/src/main/java/jospi/endpoints/Rankings.java @@ -26,7 +26,7 @@ protected Rankings(OsuApiClient client) { } public CompletableFuture getKudosuRanking(int page) { - return client.getJsonAsync("/rankings/kudosu?page"+page, User[].class); + return client.getJsonAsync("/rankings/kudosu?page" + page, User[].class); } public CompletableFuture getSpotlights() { @@ -48,7 +48,9 @@ public AsyncLazyEnumerable getRanking(Ruleset ruleset, U // REQUIRES USER public AsyncLazyEnumerable getPerformanceRanking(Ruleset ruleset, String countryCode, RankingFilter filter, String variant) { - if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser(); + if (filter.equals(RankingFilter.FRIENDS)) { + client.requiresUser(); + } AsyncLazyEnumerable enumerableBundle = getRankingInternal(ruleset, UserRankingType.PERFORMANCE, countryCode, filter, null, variant); Function, CompletableFuture> func = (CompletableFuture bundle) -> { return CompletableFuture.supplyAsync(() -> ClientUtil.awaitTask(bundle).getRankings()); @@ -57,7 +59,9 @@ public AsyncLazyEnumerable getPerformanceRanking(Rules } public AsyncLazyEnumerable getSpotlightRanking(Ruleset ruleset, RankingFilter filter, String spotlightId) { - if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser(); + if (filter.equals(RankingFilter.FRIENDS)) { + client.requiresUser(); + } AsyncLazyEnumerable enumerableBundle = getRankingInternal(ruleset, UserRankingType.PERFORMANCE, null, filter, spotlightId, null); Function, CompletableFuture> func = (CompletableFuture bundle) -> { return CompletableFuture.supplyAsync(() -> (new SpotlightRankings(ClientUtil.awaitTask(bundle)))); @@ -66,7 +70,9 @@ public AsyncLazyEnumerable getSpotlightRanking(Rulese } public AsyncLazyEnumerable getRanking(Ruleset ruleset, UserRankingType type, RankingFilter filter) { - if (filter.equals(RankingFilter.FRIENDS)) client.requiresUser(); + if (filter.equals(RankingFilter.FRIENDS)) { + client.requiresUser(); + } return getRankingInternal(ruleset, type, null, filter, null, null); } diff --git a/src/main/java/jospi/endpoints/Users.java b/src/main/java/jospi/endpoints/Users.java index af9907c..b9633ba 100644 --- a/src/main/java/jospi/endpoints/Users.java +++ b/src/main/java/jospi/endpoints/Users.java @@ -30,16 +30,16 @@ public CompletableFuture getOwnData() { public CompletableFuture getOwnData(Ruleset ruleset) { client.requiresUser(); - return client.getJsonAsync("/me/"+ClientUtil.nullishCoalesce(ruleset, ""), UserExtended.class); + return client.getJsonAsync("/me/" + ClientUtil.nullishCoalesce(ruleset, ""), UserExtended.class); } public CompletableFuture getKudosuHistory(int userId, UserResultParams params) { - return client.getJsonAsync(BASE+userId+"/kudosu", params.convert(), KudosuHistoryEntry[].class); + return client.getJsonAsync(BASE + userId + "/kudosu", params.convert(), KudosuHistoryEntry[].class); } public CompletableFuture getUserScores(int userId, UserScoreType type, boolean legacyOnly, boolean includeFails, Ruleset ruleset, UserResultParams usrParams) { - return client.getJsonAsync(BASE+userId+"/scores/"+type.getDescription(), map -> { + return client.getJsonAsync(BASE + userId + "/scores/" + type.getDescription(), map -> { map.put("legacy_only", legacyOnly); map.put("include_fails", includeFails); map.put("mode", ruleset); @@ -48,14 +48,14 @@ public CompletableFuture getUserScores(int userId, UserScoreType type, } public CompletableFuture getUserMostPlayed(int userId, UserResultParams params) { - return client.getJsonAsync(BASE+userId+"/beatmapsets/"+BeatmapType.MOST_PLAYED.getDescription(), params.convert(), BeatmapPlaycount[].class); + return client.getJsonAsync(BASE + userId + "/beatmapsets/" + BeatmapType.MOST_PLAYED.getDescription(), params.convert(), BeatmapPlaycount[].class); } public CompletableFuture getUserBeatmaps(int userId, BeatmapType type, UserResultParams params) { if (type==BeatmapType.MOST_PLAYED) { throw new IllegalArgumentException("Please use GetUserMostPlayed(), as the response type differs."); } - return client.getJsonAsync(BASE+userId+"/beatmapsets/"+type.getDescription(), params.convert(), BeatmapSetExtended[].class); + return client.getJsonAsync(BASE + userId + "/beatmapsets/" + type.getDescription(), params.convert(), BeatmapSetExtended[].class); } public CompletableFuture getUser(int userId, Ruleset ruleset) { @@ -63,20 +63,22 @@ public CompletableFuture getUser(int userId, Ruleset ruleset) { } public CompletableFuture getUser(String username, Ruleset ruleset) { - return getUserInternal("@"+username, ruleset); + return getUserInternal("@" + username, ruleset); } private CompletableFuture getUserInternal(String userIdentifier, Ruleset ruleset) { - return client.getJsonAsync(BASE+userIdentifier+"/"+ClientUtil.nullishCoalesce(ruleset, ""), User.class); + return client.getJsonAsync(BASE + userIdentifier + "/" + ClientUtil.nullishCoalesce(ruleset, ""), User.class); } public CompletableFuture getUsers(int[] ids, boolean includeVariantStatistics) { - if (ids.length>50) { + if (ids.length > 50) { throw new IndexOutOfBoundsException("Parameter 'ids' can only have an array length of 50 or less"); } return client.getJsonAsync(BASE, map -> { map.put("include_variant_statistics", includeVariantStatistics); - for (int id : ids) map.put("ids[]", id); + for (int id : ids) { + map.put("ids[]", id); + } }, User[].class); } } diff --git a/src/main/java/jospi/endpoints/Wikis.java b/src/main/java/jospi/endpoints/Wikis.java index 941f92a..6bdf9de 100644 --- a/src/main/java/jospi/endpoints/Wikis.java +++ b/src/main/java/jospi/endpoints/Wikis.java @@ -14,6 +14,6 @@ protected Wikis(OsuApiClient client) { } public CompletableFuture getWikiPage(String locale, String path) { - return client.getJsonAsync("/wiki/"+locale+"/"+path, WikiPage.class); + return client.getJsonAsync("/wiki/" + locale + "/" + path, WikiPage.class); } } diff --git a/src/main/java/jospi/enums/changelogs/ChangelogEntryCategory.java b/src/main/java/jospi/enums/changelogs/ChangelogEntryCategory.java index b196878..6012962 100644 --- a/src/main/java/jospi/enums/changelogs/ChangelogEntryCategory.java +++ b/src/main/java/jospi/enums/changelogs/ChangelogEntryCategory.java @@ -42,7 +42,7 @@ public enum ChangelogEntryCategory implements DescriptionEnum { private String description; - private ChangelogEntryCategory(String description) { + ChangelogEntryCategory(String description) { this.description = description; } diff --git a/src/main/java/jospi/iterator/AsyncLazyEnumerable.java b/src/main/java/jospi/iterator/AsyncLazyEnumerable.java index 6668475..6374afc 100644 --- a/src/main/java/jospi/iterator/AsyncLazyEnumerable.java +++ b/src/main/java/jospi/iterator/AsyncLazyEnumerable.java @@ -8,10 +8,13 @@ import java.util.concurrent.ExecutionException; import java.util.function.Function; +import lombok.Getter; + public class AsyncLazyEnumerable implements Iterable> { private final Function, CompletableFuture> enumerator; private final ExitToken token; private final ExitType type; + @Getter private List> cache; public AsyncLazyEnumerable(Function, CompletableFuture> func, ExitToken token) { @@ -24,10 +27,6 @@ public AsyncLazyEnumerable(Function, CompletableFuture> func, Ex this.type = type; } - public List> getCache() { - return cache; - } - public List> asList() { List> out = new ArrayList<>(); try { @@ -36,7 +35,7 @@ public List> asList() { moveNextAsync(); } } catch (InterruptedException | ExecutionException e) { - if (e.getClass()==InterruptedException.class) { + if (e.getClass() == InterruptedException.class) { Thread.currentThread().interrupt(); } e.printStackTrace(); @@ -50,22 +49,24 @@ public AsyncLazyEnumerable append(Function, Compl } public CompletableFuture current() { - if (type==ExitType.WHILE) { - if (token.doExit()) return null; - else { + if (type == ExitType.WHILE) { + if (token.doExit()) { + return null; + } else { CompletableFuture out = enumerator.apply(token); cache.add(out); return out; } - } else if (type==ExitType.DO_WHILE) { - if (type.getState()==0) { + } else if (type == ExitType.DO_WHILE) { + if (type.getState() == 0) { type.setState(1); CompletableFuture out = enumerator.apply(token); cache.add(out); return out; } else { - if (token.doExit()) return null; - else { + if (token.doExit()) { + return null; + } else { CompletableFuture out = enumerator.apply(token); cache.add(out); return out; @@ -76,8 +77,8 @@ public CompletableFuture current() { } public CompletableFuture moveNextAsync() { - synchronized(this) { - if (token.getNext()!=null) { + synchronized (this) { + if (token.getNext() != null) { return CompletableFuture.supplyAsync(() -> { token.setToken(token.getNext()); return Boolean.TRUE; @@ -103,7 +104,7 @@ public AsyncLazyEnumerator(AsyncLazyEnumerable instance) { @Override public boolean hasNext() { - return instance.token.getNext()!=null; + return instance.token.getNext() != null; } @Override diff --git a/src/main/java/jospi/iterator/ExitToken.java b/src/main/java/jospi/iterator/ExitToken.java index 2eb8a44..1d65107 100644 --- a/src/main/java/jospi/iterator/ExitToken.java +++ b/src/main/java/jospi/iterator/ExitToken.java @@ -3,6 +3,11 @@ import java.util.Objects; import java.util.function.Function; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter public class ExitToken { private T token; private T next; @@ -16,23 +21,7 @@ public ExitToken(T token, Function eval) { this.token = token; this.evaluate = eval; } - - public T getToken() { - return this.token; - } - - public void setToken(T token) { - this.token = token; - } - - public T getNext() { - return this.next; - } - - public void setNext(T next) { - this.next = next; - } - + public boolean doExit() { return evaluate.apply(token); } diff --git a/src/main/java/jospi/models/generic/Text.java b/src/main/java/jospi/models/generic/Text.java index debb569..26ccd62 100644 --- a/src/main/java/jospi/models/generic/Text.java +++ b/src/main/java/jospi/models/generic/Text.java @@ -20,5 +20,5 @@ public class Text { @JsonProperty("raw") private String raw; - private String markup = bbcode!=null? bbcode : raw; + private String markup = bbcode != null ? bbcode : raw; } diff --git a/src/main/java/jospi/models/home/SearchResult.java b/src/main/java/jospi/models/home/SearchResult.java index 44d2d9c..b3e4fe1 100644 --- a/src/main/java/jospi/models/home/SearchResult.java +++ b/src/main/java/jospi/models/home/SearchResult.java @@ -28,8 +28,12 @@ public static Map process(SearchResul List userEntries = new ArrayList<>(); List wikiPageEntries = new ArrayList<>(); for (T element : instance.getData()) { - if (element instanceof User) userEntries.add((User) element); - if (element instanceof WikiPage) wikiPageEntries.add((WikiPage) element); + if (element instanceof User) { + userEntries.add((User) element); + } + if (element instanceof WikiPage) { + wikiPageEntries.add((WikiPage) element); + } } Map result = new ConcurrentHashMap<>(); result.put("user_entries", userEntries); diff --git a/src/main/java/jospi/models/records/HttpRecord.java b/src/main/java/jospi/models/records/HttpRecord.java index 3224533..50674cd 100644 --- a/src/main/java/jospi/models/records/HttpRecord.java +++ b/src/main/java/jospi/models/records/HttpRecord.java @@ -4,8 +4,8 @@ import java.util.Map; public interface HttpRecord { - public default Map convert() { + default Map convert() { return convert(new HashMap<>()); } - public Map convert(Map map); + Map convert(Map map); } diff --git a/src/main/java/jospi/models/users/GroupDescription.java b/src/main/java/jospi/models/users/GroupDescription.java index 27ac34d..f19b22a 100644 --- a/src/main/java/jospi/models/users/GroupDescription.java +++ b/src/main/java/jospi/models/users/GroupDescription.java @@ -14,11 +14,11 @@ public class GroupDescription { /// The description of this group, as a pre-rendered HTML string. /// @JsonProperty("html") - public String html; + private String html; /// /// The description of this group, as a markdown string. /// @JsonProperty("markdown") - public String markdown; + private String markdown; } diff --git a/src/main/java/jospi/models/users/HighestRank.java b/src/main/java/jospi/models/users/HighestRank.java index 4291f43..24ba469 100644 --- a/src/main/java/jospi/models/users/HighestRank.java +++ b/src/main/java/jospi/models/users/HighestRank.java @@ -17,5 +17,5 @@ public class HighestRank { private int rank; @JsonProperty("updated_at") - public OffsetDateTime updatedAt; + private OffsetDateTime updatedAt; } diff --git a/src/main/java/jospi/models/users/Kudosu.java b/src/main/java/jospi/models/users/Kudosu.java index 4915f7e..192cebf 100644 --- a/src/main/java/jospi/models/users/Kudosu.java +++ b/src/main/java/jospi/models/users/Kudosu.java @@ -11,8 +11,8 @@ @NoArgsConstructor public class Kudosu { @JsonProperty("available") - public int available; + private int available; @JsonProperty("total") - public int total; + private int total; }