From e49d39008928490fd19c92ff5c8bb3c65c6092b7 Mon Sep 17 00:00:00 2001 From: delvh Date: Thu, 23 Jul 2020 18:51:20 +0200 Subject: [PATCH] Apply suggestions from code review (1) Co-authored-by: CyB3RC0nN0R --- .../java/envoy/client/data/commands/OnCall.java | 3 --- .../envoy/client/data/commands/SystemCommand.java | 15 ++++++--------- .../client/data/commands/SystemCommandsMap.java | 11 +++++------ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/client/src/main/java/envoy/client/data/commands/OnCall.java b/client/src/main/java/envoy/client/data/commands/OnCall.java index 3dbc18e..dc9c015 100644 --- a/client/src/main/java/envoy/client/data/commands/OnCall.java +++ b/client/src/main/java/envoy/client/data/commands/OnCall.java @@ -18,9 +18,6 @@ public interface OnCall { /** * Performs class specific actions when a {@link SystemCommand} has been called. * - * The action that should be performed when this {@link SystemCommand} has been - * called. - * * @since Envoy Client v0.2-beta */ void onCall(); diff --git a/client/src/main/java/envoy/client/data/commands/SystemCommand.java b/client/src/main/java/envoy/client/data/commands/SystemCommand.java index f0b6a29..17ea801 100644 --- a/client/src/main/java/envoy/client/data/commands/SystemCommand.java +++ b/client/src/main/java/envoy/client/data/commands/SystemCommand.java @@ -24,13 +24,12 @@ import java.util.function.Supplier; public class SystemCommand implements OnCall { /** - * This variable stores the amount of arguments that need to be parsed for the - * underlying function. + * The argument count of the command. */ protected final int numberOfArguments; /** - * This Function takes a {@code String[]} as argument because automatically + * This function takes a {@code String[]} as argument because automatically * {@code SystemCommand#numberOfArguments} words following the necessary command * will be put into this array. * @@ -40,14 +39,13 @@ public class SystemCommand implements OnCall { protected final String description; - protected int relevance = 0; + protected int relevance; /** * Constructs a new {@code SystemCommand}. * - * @param action the action that should be performed - * @param numberOfArguments the amount of arguments that need to be parsed for - * the underlying function + * @param action the action performed by the command + * @param numberOfArguments the argument count accepted by the action * @param description the description of this {@code SystemCommand} * @since Envoy Client v0.2-beta */ @@ -64,8 +62,7 @@ public class SystemCommand implements OnCall { public Function getAction() { return action; } /** - * @return the amount of arguments that need to be parsed for - * the underlying function + * @return the argument count of the command * @since Envoy Client v0.2-beta */ public int getNumberOfArguments() { return numberOfArguments; } diff --git a/client/src/main/java/envoy/client/data/commands/SystemCommandsMap.java b/client/src/main/java/envoy/client/data/commands/SystemCommandsMap.java index a9c6c84..4ba6dfb 100644 --- a/client/src/main/java/envoy/client/data/commands/SystemCommandsMap.java +++ b/client/src/main/java/envoy/client/data/commands/SystemCommandsMap.java @@ -19,7 +19,7 @@ import envoy.util.EnvoyLog; * @author Leon Hofmeister * @since Envoy Client v0.2-beta */ -public class SystemCommandsMap { +public final class SystemCommandsMap { private final HashMap systemCommands = new HashMap<>(); @@ -27,11 +27,10 @@ public class SystemCommandsMap { private static final Logger logger = EnvoyLog.getLogger(SystemCommandsMap.class); - private boolean commandExecuted = false; + private boolean commandExecuted; /** - * Adds a command with according action and the number of arguments that should - * be parsed if the command does not violate API constrictions to the map. + * Adds a new command to the map if the command name is valid. * * @param command the string that must be inputted to execute the * given action @@ -124,9 +123,9 @@ public class SystemCommandsMap { * @return whether this key can be used in the map * @since Envoy Client v0.2-beta */ - public final boolean isValidKey(String command) { + public boolean isValidKey(String command) { final boolean valid = commandBounds.matcher(command).matches(); - if (!valid) EnvoyLog.getLogger(SystemCommandsMap.class) + if (!valid) logger .log(Level.WARNING, "The command \"" + command + "\" is not valid. As it will cause problems in execution, it will not be entered into the map. Only the characters "