Class ArgSet

java.lang.Object
com.j3d.engine.interact.cmd.args.ArgSet
All Implemented Interfaces:
Argument

public class ArgSet extends Object implements Argument
A special type of string argument that can take a set of predefined string values. Useful for commands that have options or modes.

ArgSets typically are in the form of [value1|value2|value3] in string form, however that form may also be used to define subcommands who take in the exact same amount and type of parameters.

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • allowedValues

      private final ArrayList<String> allowedValues
    • name

      private final String name
    • description

      private final String description
    • isOptional

      private final boolean isOptional
  • Constructor Details

    • ArgSet

      public ArgSet(String name, String description, boolean isOptional, String... allowedValues)
      Constructor for arg set
      Parameters:
      name - The name of the argument
      description - The description of the argument
      isOptional - Whether the argument is optional
      allowedValues - The allowed values for the argument
  • Method Details

    • getAllowedValues

      public ArrayList<String> getAllowedValues()
      Retrieves the values that this arg set allows.
      Returns:
      The allowed values for the argument
    • isValid

      public boolean isValid(String value)
      Checks whether a given value is valid for this arg set.
      Parameters:
      value - The value to check
      Returns:
      True if the value is valid, false otherwise
    • getName

      public String getName()
      Description copied from interface: Argument
      Returns the name of the argument.

      This is the identifier used by the command parser to refer to this argument.

      Specified by:
      getName in interface Argument
      Returns:
      The name of the argument.
    • getDescription

      public String getDescription()
      Description copied from interface: Argument
      Provides a user-friendly description of what the argument does.

      This is typically used for generating help text or tooltips.

      Specified by:
      getDescription in interface Argument
      Returns:
      A brief description of the argument's purpose.
    • isOptional

      public boolean isOptional()
      Description copied from interface: Argument
      Specifies whether the argument is optional or required for the command to execute.
      Specified by:
      isOptional in interface Argument
      Returns:
      true if the argument is optional, false if it is required.
    • toUseString

      public String toUseString()