Added System Commands basics - may change again

This commit is contained in:
delvh 2020-07-17 00:23:35 +02:00
parent e104a1f9b4
commit 71145bbb24
4 changed files with 115 additions and 0 deletions

View File

@ -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.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>NoArgSystemCommand.java</strong><br>
* Created: <strong>16.07.2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.1-beta
*/
public class NoArgSystemCommand extends SystemCommand<Void> {
/**
* 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<Void, Void> action) { super(command, action); }
}

View File

@ -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.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>StringArgSystemCommand.java</strong><br>
* Created: <strong>16.07.2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.1-beta
*/
public class StringArgSystemCommand extends SystemCommand<String> {
/**
* 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<String, Void> action) { super(command, action); }
}

View File

@ -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.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>SystemCommand.java</strong><br>
* Created: <strong>16.07.2020</strong><br>
*
* @author Leon Hofmeister
* @param <T> the type of argument needed
* @since Envoy Client v0.1-beta
*/
public abstract class SystemCommand<T> {
/**
* This variable stores the command that should be inputted to execute the given
* action
*/
protected final String command;
protected final Function<T, Void> 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<T, Void> 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<T, Void> getAction() { return action; }
}

View File

@ -0,0 +1,12 @@
/**
* This package contains all classes that can be used as system commands.<br>
* Every system command can be called using a specific syntax:"/&lt;command&gt;"
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>package-info.java</strong><br>
* Created: <strong>16.07.2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.1-beta
*/
package envoy.client.data.commands;