Class TypedArg

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

public class TypedArg extends Object implements Argument
Represents a command argument that is expected to be of a specific type or one of several allowed types.

This class is used to define arguments that require type validation. For example, an argument might be required to be a Double, a String, or a specific graphics object like a GPoint. This information is crucial for both parsing user input and for auto-generating accurate command usage strings.

See Also:
  • Field Details

    • type

      private final ArrayList<Class> type
      A list of Class objects representing the allowed types for this argument.
    • name

      private final String name
    • description

      private final String description
    • optional

      private final boolean optional
  • Constructor Details

    • TypedArg

      public TypedArg(String name, String description, boolean optional, Class<?>... type)
      Constructs a new TypedArg.
      Parameters:
      name - The name of the argument.
      description - A user-friendly description of the argument's purpose.
      optional - true if the argument is optional, false if it is required.
      type - A varargs array of Class objects representing the allowed types.
  • Method Details

    • getType

      public ArrayList<Class> getType()
      Returns the list of allowed types for this argument.
      Returns:
      An ArrayList of Class objects.
    • 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.