Class Command

java.lang.Object
commandManagers.Command
All Implemented Interfaces:
CommandInterface
Direct Known Subclasses:
Add, AddIfMin, Clear, ExecuteScript, Exit, Help, History, Info, PrintDescending, PrintFieldDescendingMetersAboveSeaLevel, RemoveById, RemoveGreater, Save, Show, SumOfMetersAboveSeaLevel, UpdateId

public abstract class Command extends Object implements CommandInterface
Abstract class representing a command that can be executed in the program.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Command(boolean hasArgument)
    Constructs a new command with the specified argument requirement.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    checkArgument(Object inputArgument)
    Checks if the given inputArgument is valid for this command.
    abstract void
    Executes command.
    Returns the argument for this command.
    abstract String
    Base method for show command description.
    abstract String
    Base method for show command name
    boolean
    Returns whether this command requires an argument.
    void
    setArgument(String argument)
    Sets the argument for this command.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Command

      public Command(boolean hasArgument)
      Constructs a new command with the specified argument requirement.
      Parameters:
      hasArgument - a boolean indicating whether this command requires an argument or not.
  • Method Details

    • getName

      public abstract String getName()
      Base method for show command name
      Specified by:
      getName in interface CommandInterface
      Returns:
      command name
    • getDescr

      public abstract String getDescr()
      Base method for show command description.
      Specified by:
      getDescr in interface CommandInterface
      Returns:
      command description
    • execute

      public abstract void execute() throws BuildObjectException
      Executes command.
      Specified by:
      execute in interface CommandInterface
      Throws:
      BuildObjectException
    • checkArgument

      public abstract boolean checkArgument(Object inputArgument)
      Checks if the given inputArgument is valid for this command.
      Specified by:
      checkArgument in interface CommandInterface
      Parameters:
      inputArgument - the argument to check.
      Returns:
      true if the argument is valid, false otherwise.
    • isHasArgument

      public boolean isHasArgument()
      Returns whether this command requires an argument.
      Returns:
      true if this command requires an argument, false otherwise.
    • getArgument

      public Object getArgument()
      Returns the argument for this command.
      Returns:
      the argument for this command.
    • setArgument

      public void setArgument(String argument)
      Sets the argument for this command.
      Parameters:
      argument - the argument to set.