Apply suggestions from code review (1)
Co-authored-by: CyB3RC0nN0R <kske@outlook.de>
This commit is contained in:
parent
85cfa2c789
commit
2af78f1562
@ -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();
|
||||
|
@ -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<String[], Void> 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; }
|
||||
|
@ -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<String, SystemCommand> 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 "
|
||||
|
Reference in New Issue
Block a user