Class RegisterArgumentParser<T>

java.lang.Object
net.apartium.cocoabeans.commands.parsers.ArgumentParser<T>
net.apartium.cocoabeans.commands.RegisterArgumentParser<T>
Type Parameters:
T - result type of the parser
All Implemented Interfaces:
Comparable<ArgumentParser<?>>

@AvailableSince("0.0.37") public class RegisterArgumentParser<T> extends ArgumentParser<T>
A register argument parser is a wrapper for an argument parser Used for registering argument parsers because we need extra information for register argument parser
See Also:
  • Constructor Details

    • RegisterArgumentParser

      public RegisterArgumentParser(ArgumentParser<T> parser, boolean optionalNotMatch, boolean isOptional, String parameterName)
      A constructor for a register argument parser
      Parameters:
      parser - argument parser
      optionalNotMatch - return optional if not match the parser
      isOptional - could we don't use the parser and return optional
      parameterName - parameter name will be used for better parameter control
  • Method Details

    • parser

      public ArgumentParser<T> parser()
      Get the argument parser that this register argument parser wraps
      Returns:
      the argument parser
    • optionalNotMatch

      public boolean optionalNotMatch()
      Get if the argument parser accept optional but does not match
      Returns:
      if the argument parser accept optional but does not match
    • isOptional

      public boolean isOptional()
      Get if the argument parser accept no argument
      Returns:
      if the argument parser accept no argument
    • getParameterName

      public Optional<String> getParameterName()
      Get the parameter name
      Returns:
      the parameter name
    • parse

      public Optional<ArgumentParser.ParseResult<T>> parse(CommandProcessingContext processingContext)
      Tries to parse next argument in the context
      Specified by:
      parse in class ArgumentParser<T>
      Parameters:
      processingContext - cmd processing context
      Returns:
      empty if failed, otherwise result
    • tryParse

      public OptionalInt tryParse(CommandProcessingContext processingContext)
      Tries to lazily parse next argument in the context
      Specified by:
      tryParse in class ArgumentParser<T>
      Parameters:
      processingContext - cmd processing context
      Returns:
      new index int if success, empty if not
    • tabCompletion

      public Optional<ArgumentParser.TabCompletionResult> tabCompletion(CommandProcessingContext processingContext)
      Retrieves available options for tab completion of this argument
      Specified by:
      tabCompletion in class ArgumentParser<T>
      Parameters:
      processingContext - cmd processing context
      Returns:
      tab completion result if success, otherwise empty option
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object