Added System Commands basics - may change again
This commit is contained in:
parent
9dd4c48f62
commit
ce3a4a8979
@ -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); }
|
||||
}
|
@ -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); }
|
||||
}
|
@ -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; }
|
||||
}
|
@ -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:"/<command>"
|
||||
* <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;
|
Reference in New Issue
Block a user