Skip to content

Commit 915f73a

Browse files
committed
change to getFirst() and getLast()
1 parent 9122c16 commit 915f73a

File tree

20 files changed

+26
-26
lines changed

20 files changed

+26
-26
lines changed

application/src/main/java/org/togetherjava/tjbot/features/bookmarks/BookmarksListRemoveHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Request withSelectedBookmarksToRemove(Set<Long> selectedBookmarkIdsToRemove) {
314314
}
315315

316316
static Request fromArgs(List<String> args) {
317-
RequestType requestType = RequestType.valueOf(args.get(0));
317+
RequestType requestType = RequestType.valueOf(args.getFirst());
318318
String componentName = args.get(1);
319319
int currentPageIndex = Integer.parseInt(args.get(2));
320320

application/src/main/java/org/togetherjava/tjbot/features/code/CodeMessageHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private Button createButtonForAction(CodeAction action, long originalMessageId)
152152

153153
@Override
154154
public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
155-
long originalMessageId = Long.parseLong(args.get(0));
155+
long originalMessageId = Long.parseLong(args.getFirst());
156156

157157
event.deferEdit().queue();
158158

application/src/main/java/org/togetherjava/tjbot/features/filesharing/FileSharingMessageListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
9898
@Override
9999
public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
100100
Member interactionUser = event.getMember();
101-
String gistAuthorId = args.get(0);
101+
String gistAuthorId = args.getFirst();
102102
boolean hasSoftModPermissions =
103103
interactionUser.getRoles().stream().map(Role::getName).anyMatch(isSoftModRole);
104104

application/src/main/java/org/togetherjava/tjbot/features/github/GitHubReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
120120
List<MessageEmbed> embeds = new ArrayList<>();
121121

122122
while (matcher.find()) {
123-
long defaultRepoId = config.getGitHubRepositories().get(0);
123+
long defaultRepoId = config.getGitHubRepositories().getFirst();
124124

125125
int issueId = Integer.parseInt(matcher.group(ID_GROUP));
126126
findIssue(issueId, defaultRepoId).ifPresent(issue -> embeds.add(generateReply(issue)));

application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private static ForumTag requireTag(String tagName, ForumChannel forumChannel) {
320320
.formatted(forumChannel.getName(), forumChannel.getGuild().getName(), tagName));
321321
}
322322

323-
return matchingTags.get(0);
323+
return matchingTags.getFirst();
324324
}
325325

326326
boolean hasTagManageRole(Member member) {

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private void resetActivity(SlashCommandInteractionEvent event, ThreadChannel hel
213213

214214
helpThread.getHistory()
215215
.retrievePast(1)
216-
.map(messages -> messages.get(0))
216+
.map(messages -> messages.getFirst())
217217
.queue(lastMessage -> manuallyResetChannelActivityCache.put(helpThread.getIdLong(),
218218
lastMessage.getIdLong()));
219219

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private boolean isPostAuthor(Member interactionUser, Message message) {
180180
}
181181

182182
String embedAuthor = Objects
183-
.requireNonNull(message.getEmbeds().get(0).getAuthor(),
183+
.requireNonNull(message.getEmbeds().getFirst().getAuthor(),
184184
"embed author for forum post is null")
185185
.getName();
186186

application/src/main/java/org/togetherjava/tjbot/features/mathcommands/TeXCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private boolean isInvalidInlineFormat(String latex) {
164164

165165
@Override
166166
public void onButtonClick(final ButtonInteractionEvent event, final List<String> args) {
167-
if (!args.get(0).equals(Objects.requireNonNull(event.getMember()).getId())) {
167+
if (!args.getFirst().equals(Objects.requireNonNull(event.getMember()).getId())) {
168168
event.reply("You are not the person who executed the command, you cannot do that")
169169
.setEphemeral(true)
170170
.queue();

application/src/main/java/org/togetherjava/tjbot/features/moderation/ReportCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private static String createUserReply(Result<Message> result) {
223223
private record ReportedMessage(String content, String id, String jumpUrl, String channelID,
224224
Instant timestamp, String authorName, String authorAvatarUrl) {
225225
static ReportedMessage ofArgs(List<String> args) {
226-
String content = args.get(0);
226+
String content = args.getFirst();
227227
String id = args.get(1);
228228
String jumpUrl = args.get(2);
229229
String channelID = args.get(3);

application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void onMessageContext(MessageContextInteractionEvent event) {
9595
String originalMessageId = event.getTarget().getId();
9696
String originalChannelId = event.getTarget().getChannel().getId();
9797
String authorId = event.getTarget().getAuthor().getId();
98-
String mostCommonTag = tags.get(0);
98+
String mostCommonTag = tags.getFirst();
9999
String chatGptPrompt =
100100
"Summarize the following text into a concise title or heading not more than 4-5 words, remove quotations if any: %s"
101101
.formatted(originalMessage);
@@ -142,7 +142,7 @@ public void onMessageContext(MessageContextInteractionEvent event) {
142142
public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
143143
event.deferReply(true).queue();
144144

145-
String authorId = args.get(0);
145+
String authorId = args.getFirst();
146146
String messageId = args.get(1);
147147
String channelId = args.get(2);
148148
ForumChannel helperForum = getHelperForum(event.getJDA());
@@ -226,13 +226,13 @@ private RestAction<ForumPostData> createForumPost(ModalInteractionEvent event,
226226
String transferQuestionTag = event.getValue(MODAL_TAG).getAsString();
227227

228228
ForumChannel questionsForum = getHelperForum(event.getJDA());
229-
String mostCommonTag = tags.get(0);
229+
String mostCommonTag = tags.getFirst();
230230

231231
String queryTag =
232232
StringDistances.closestMatch(transferQuestionTag, tags).orElse(mostCommonTag);
233233

234234
ForumTag tag = getTagOrDefault(questionsForum.getAvailableTagsByName(queryTag, true),
235-
() -> questionsForum.getAvailableTagsByName(mostCommonTag, true).get(0));
235+
() -> questionsForum.getAvailableTagsByName(mostCommonTag, true).getFirst());
236236

237237
return questionsForum.createForumPost(forumTitle, forumMessage)
238238
.setTags(ForumTagSnowflake.fromId(tag.getId()))
@@ -279,7 +279,7 @@ private ForumChannel getHelperForum(JDA jda) {
279279

280280
private static ForumTag getTagOrDefault(List<ForumTag> tagsFoundOnForum,
281281
Supplier<ForumTag> defaultTag) {
282-
return tagsFoundOnForum.isEmpty() ? defaultTag.get() : tagsFoundOnForum.get(0);
282+
return tagsFoundOnForum.isEmpty() ? defaultTag.get() : tagsFoundOnForum.getFirst();
283283
}
284284

285285
private MessageEmbed makeEmbedForPost(User originalUser, String originalMessage) {

0 commit comments

Comments
 (0)