From 71145bbb244a3dcec75c587db429d9e3adda87f2 Mon Sep 17 00:00:00 2001 From: delvh Date: Fri, 17 Jul 2020 00:23:35 +0200 Subject: [PATCH] Added System Commands basics - may change again --- .../data/commands/NoArgSystemCommand.java | 26 ++++++++++ .../data/commands/StringArgSystemCommand.java | 26 ++++++++++ .../client/data/commands/SystemCommand.java | 51 +++++++++++++++++++ .../client/data/commands/package-info.java | 12 +++++ 4 files changed, 115 insertions(+) create mode 100644 client/src/main/java/envoy/client/data/commands/NoArgSystemCommand.java create mode 100644 client/src/main/java/envoy/client/data/commands/StringArgSystemCommand.java create mode 100644 client/src/main/java/envoy/client/data/commands/SystemCommand.java create mode 100644 client/src/main/java/envoy/client/data/commands/package-info.java diff --git a/client/src/main/java/envoy/client/data/commands/NoArgSystemCommand.java b/client/src/main/java/envoy/client/data/commands/NoArgSystemCommand.java new file mode 100644 index 0000000..4968c58 --- /dev/null +++ b/client/src/main/java/envoy/client/data/commands/NoArgSystemCommand.java @@ -0,0 +1,26 @@ +package envoy.client.data.commands; + +import java.util.function.Function; + +/** + * This class is the base class for all {@link SystemCommand}s that do not need + * another argument to parse their function. + *

+ * Project: envoy-client
+ * File: NoArgSystemCommand.java
+ * Created: 16.07.2020
+ * + * @author Leon Hofmeister + * @since Envoy Client v0.1-beta + */ +public class NoArgSystemCommand extends SystemCommand { + + /** + * Constructs a new {@code NoArgSystemCommand} that takes no arguments. + * + * @param command the string that must be inputted to execute the given action + * @param action the action that should be performed + * @since Envoy Client v0.1-beta + */ + public NoArgSystemCommand(String command, Function action) { super(command, action); } +} diff --git a/client/src/main/java/envoy/client/data/commands/StringArgSystemCommand.java b/client/src/main/java/envoy/client/data/commands/StringArgSystemCommand.java new file mode 100644 index 0000000..5349724 --- /dev/null +++ b/client/src/main/java/envoy/client/data/commands/StringArgSystemCommand.java @@ -0,0 +1,26 @@ +package envoy.client.data.commands; + +import java.util.function.Function; + +/** + * This class is the base class for all {@link SystemCommand}s that need a + * String to parse their function. + *

+ * Project: envoy-client
+ * File: StringArgSystemCommand.java
+ * Created: 16.07.2020
+ * + * @author Leon Hofmeister + * @since Envoy Client v0.1-beta + */ +public class StringArgSystemCommand extends SystemCommand { + + /** + * Constructs a new {@code NoArgSystemCommand} that takes a String argument. + * + * @param command the string that must be inputted to execute the given action + * @param action the action that should be performed + * @since Envoy Client v0.1-beta + */ + public StringArgSystemCommand(String command, Function action) { super(command, action); } +} diff --git a/client/src/main/java/envoy/client/data/commands/SystemCommand.java b/client/src/main/java/envoy/client/data/commands/SystemCommand.java new file mode 100644 index 0000000..793de46 --- /dev/null +++ b/client/src/main/java/envoy/client/data/commands/SystemCommand.java @@ -0,0 +1,51 @@ +package envoy.client.data.commands; + +import java.util.function.Function; + +/** + * This class is the base class of all {@code SystemCommands} and contains an + * action and a command that needs to be inputted to execute the given action. + * No {@code SystemCommand} can return anything. + *

+ * Project: envoy-client
+ * File: SystemCommand.java
+ * Created: 16.07.2020
+ * + * @author Leon Hofmeister + * @param the type of argument needed + * @since Envoy Client v0.1-beta + */ +public abstract class SystemCommand { + + /** + * This variable stores the command that should be inputted to execute the given + * action + */ + protected final String command; + + protected final Function action; + + /** + * Constructs a new {@code NoArgSystemCommand} that takes no arguments. + * + * @param command the string that must be inputted to execute the given action + * @param action the action that should be performed + * @since Envoy Client v0.1-beta + */ + public SystemCommand(String command, Function action) { + this.command = command; + this.action = action; + } + + /** + * @return the command that must be inputted to execute the given action + * @since Envoy Client v0.1-beta + */ + public String getCommand() { return command; } + + /** + * @return the action that should be performed + * @since Envoy Client v0.1-beta + */ + public Function getAction() { return action; } +} diff --git a/client/src/main/java/envoy/client/data/commands/package-info.java b/client/src/main/java/envoy/client/data/commands/package-info.java new file mode 100644 index 0000000..e123e81 --- /dev/null +++ b/client/src/main/java/envoy/client/data/commands/package-info.java @@ -0,0 +1,12 @@ +/** + * This package contains all classes that can be used as system commands.
+ * Every system command can be called using a specific syntax:"/<command>" + *

+ * Project: envoy-client
+ * File: package-info.java
+ * Created: 16.07.2020
+ * + * @author Leon Hofmeister + * @since Envoy Client v0.1-beta + */ +package envoy.client.data.commands;