Skip to content

Commit 81b6557

Browse files
committed
refactor: make consants more verbose and precise
Rename `VALUE_DELIMITER` to `OPTION_PARAM_ID_DELIMITER` and `ARG_COUNT` to `OPTIONS_PER_ROLE` for better and less ambiguous naming. The current ones do not accurately reflect what they are delimiting and where they should be used specifically, so we use more verbose names for that purpose. They are constants that aren't widely used anywhere in major places, though we should still take good care of all naming regardless for maximum code readability. Suggested-by: Zabuzard <zabuza.dev@gmail.com> Signed-off-by: Chris Sdogkos <work@chris-sdogkos.com>
1 parent 51e3149 commit 81b6557

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public class CreateRoleApplicationCommand extends SlashCommandAdapter {
4545
protected static final Color AMBIENT_COLOR = new Color(24, 221, 136, 255);
4646
private static final int OPTIONAL_ROLES_AMOUNT = 5;
4747
private static final String ROLE_COMPONENT_ID_HEADER = "application-create";
48-
private static final String VALUE_DELIMITER = "_";
49-
private static final int ARG_COUNT = 3;
48+
private static final String OPTION_PARAM_ID_DELIMITER = "_";
49+
private static final int OPTIONS_PER_ROLE = 3;
5050
private static final int MINIMUM_ANSWER_LENGTH = 50;
5151
private static final int MAXIMUM_ANSWER_LENGTH = 500;
5252

@@ -88,7 +88,7 @@ private void generateRoleOptions() {
8888
}
8989

9090
private static String generateOptionId(String name, int id) {
91-
return "%s%s%d".formatted(name, VALUE_DELIMITER, id);
91+
return "%s%s%d".formatted(name, OPTION_PARAM_ID_DELIMITER, id);
9292
}
9393

9494
@Override
@@ -190,7 +190,7 @@ private static long getIncorrectRoleArgsCount(final List<OptionMapping> args) {
190190

191191
args.stream()
192192
.map(OptionMapping::getName)
193-
.map(name -> name.split(VALUE_DELIMITER)[1])
193+
.map(name -> name.split(OPTION_PARAM_ID_DELIMITER)[1])
194194
.forEach(number -> frequencyMap.merge(number, 1, Integer::sum));
195195

196196
return frequencyMap.values().stream().filter(value -> value != 3).count();
@@ -206,7 +206,7 @@ private void addRolesToMenu(StringSelectMenu.Builder menuBuilder,
206206
final List<OptionMapping> args) {
207207
final Map<Integer, MenuRole> roles = new HashMap<>();
208208

209-
for (int i = 0; i < args.size(); i += ARG_COUNT) {
209+
for (int i = 0; i < args.size(); i += OPTIONS_PER_ROLE) {
210210
OptionMapping optionTitle = args.get(i);
211211
OptionMapping optionDescription = args.get(i + 1);
212212
OptionMapping optionEmoji = args.get(i + 2);

0 commit comments

Comments
 (0)