Skip to content

Commit 98cdec5

Browse files
committed
refactor: remove unneeded word plural helper method
The `selectWordFromCount` helper method, while serving a seemingly helpful purpose, is only used once and is also private to be used in the same class only. Besides the fact that we can technically move it somewhere more appropriate and increase its visibility so other classes can utilize it, remove the helepr method and resort to ternary operators for that one time we need to determine the plurarity of the word "minute" in our `CreateRoleApplicationCommand` class. Suggested-by: Zabuzard <zabuza.dev@gmail.com> Signed-off-by: Chris Sdogkos <work@chris-sdogkos.com>
1 parent 4690d67 commit 98cdec5

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

application/src/main/java/org/togetherjava/tjbot/features/roleapplication/CreateRoleApplicationCommand.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void onStringSelectSelection(StringSelectInteractionEvent event, List<Str
124124
}
125125

126126
long remainingMinutes = handler.getMemberCooldownMinutes(member);
127-
String correctMinutesWord = selectWordFromCount(remainingMinutes, "minute", "minutes");
127+
String correctMinutesWord = remainingMinutes == 1 ? "minute" : "minutes";
128128

129129
if (remainingMinutes > 0) {
130130
event
@@ -161,23 +161,6 @@ public void onStringSelectSelection(StringSelectInteractionEvent event, List<Str
161161
event.replyModal(modal).queue();
162162
}
163163

164-
/**
165-
* Selects and returns the appropriate singular or plural form of a word based on the given
166-
* count.
167-
*
168-
* @param singularForm the word in its singular form
169-
* @param pluralForm the word in its plural form
170-
* @param count the number used to determine whether to return the singular or plural form
171-
* @return the singular form if count equals 1, otherwise the plural form
172-
*/
173-
private String selectWordFromCount(final Number count, final String singularForm,
174-
final String pluralForm) {
175-
if (count.intValue() == 1) {
176-
return singularForm;
177-
}
178-
return pluralForm;
179-
}
180-
181164
/**
182165
* Checks a given list of passed arguments (from a user) and calculates how many roles have
183166
* missing data.

0 commit comments

Comments
 (0)