Class Command

java.lang.Object
it.meucci.commands.Command

public class Command extends Object
This class represents the command a user can type from their keyboard. It has a type and a list of arguments. Like messages, commands must be handled properly in order to show the right output and/or to do the proper action. These commands are NOT the ones used in server -> client communication. These are boilerplate code used to distinguish USER commands in an easier manner.
  • Method Details

    • validate

      public static Command validate(String command)
      Creates a command object from a String (usually, the user input). This is also a wrapper method to avoid code duplication. It calls a message validation method or a command one, depending on the type of string the user has input. It does not return null. Instead, it will provide a message of type INVALID. A message, following syntax `@username content` is automatically resolved into a command of type SEND. Cfr. CommandType.
      Parameters:
      command - The string input by the user
      Returns:
      A validated command.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getType

      public CommandType getType()
    • getArgs

      public ArrayList<String> getArgs()