java.lang.Object
java.lang.Enum<CommandsAPI>
ru.hse.germandilio.tetris.shared.commands.CommandsAPI
All Implemented Interfaces:
Serializable, Comparable<CommandsAPI>, Constable

public enum CommandsAPI extends Enum<CommandsAPI>
  • Enum Constant Details

    • STARTING_GAME

      public static final CommandsAPI STARTING_GAME
      Send when client wants to start new game with "name" argument.
    • GET_NEXT_BRICK

      public static final CommandsAPI GET_NEXT_BRICK
      Prompt for new brick.
    • LEAVE_GAME

      public static final CommandsAPI LEAVE_GAME
      Client ending game.
    • CLIENT_DISCONNECTED

      public static final CommandsAPI CLIENT_DISCONNECTED
      Client close application.
    • GET_TOP

      public static final CommandsAPI GET_TOP
      Get TOP (param) game sessions results.
    • CONNECTED

      public static final CommandsAPI CONNECTED
      Client has been successfully registered on server.
    • WAITING_FOR_NEW_GAME

      public static final CommandsAPI WAITING_FOR_NEW_GAME
      Waiting for new game start.
    • START_GAME

      public static final CommandsAPI START_GAME
      Starts game sessions on clients.
    • NEXT_BRICK

      public static final CommandsAPI NEXT_BRICK
      Passing new generated brick as parameter.
    • WAITING_FOR_END_GAME

      public static final CommandsAPI WAITING_FOR_END_GAME
      Waiting for opponent end game session.
    • END_GAME

      public static final CommandsAPI END_GAME
      End game on clients.
    • END_GAME_OPPONENT_LEAVE

      public static final CommandsAPI END_GAME_OPPONENT_LEAVE
      End game on client, because opponent leaved game.
    • SERVER_DISCONNECTED

      public static final CommandsAPI SERVER_DISCONNECTED
      Server is shut down. All clients should stop crash the games sessions.
    • TOP_RESULTS

      public static final CommandsAPI TOP_RESULTS
      Results of top 10 game sessions.
  • Method Details

    • values

      public static CommandsAPI[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CommandsAPI valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getCommandType

      public static CommandsAPI getCommandType(String stringCommand) throws IOException
      Get command type by String representation of type.
      Parameters:
      stringCommand - String representation
      Returns:
      CommandsAPI
      Throws:
      IOException
    • getArguments

      public static List<String> getArguments(CommandsAPI command, String input)
      Retrieves arguments from commands based on their type (internal number of arguments).
      Parameters:
      command - CommandsAPI command type.
      input - String representation of command with arguments. IMPORTANT: Input string SHOULD contain command name.
      Returns:
      List of String represented arguments
      Throws:
      IllegalArgumentException - If number of argument is lower than required by CommandsAPI type.
    • buildCommand

      public static String buildCommand(CommandsAPI command, String... parameters)
      Build command by provided type and String represented arguments.
      Parameters:
      command - CommandsAPI command type.
      parameters - String represented arguments
      Returns:
      String mounted command.
      Throws:
      IllegalArgumentException - if number of provided arguments mismatching with internal metadata.