Class BooleanArgument.BooleanParser<C>

  • All Implemented Interfaces:
    ArgumentParser<C,​java.lang.Boolean>
    Enclosing class:
    BooleanArgument<C>

    public static final class BooleanArgument.BooleanParser<C>
    extends java.lang.Object
    implements ArgumentParser<C,​java.lang.Boolean>
    • Constructor Summary

      Constructors 
      Constructor Description
      BooleanParser​(boolean liberal)
      Construct a new boolean parser
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isContextFree()
      Check whether or not this argument parser is context free.
      @NonNull ArgumentParseResult<java.lang.Boolean> parse​(@NonNull CommandContext<C> commandContext, @NonNull java.util.Queue<@NonNull java.lang.String> inputQueue)
      Parse command input into a command result.
      @NonNull java.util.List<@NonNull java.lang.String> suggestions​(@NonNull CommandContext<C> commandContext, @NonNull java.lang.String input)
      Get a list of suggested arguments that would be correctly parsed by this parser
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BooleanParser

        public BooleanParser​(boolean liberal)
        Construct a new boolean parser
        Parameters:
        liberal - Whether or not it'll accept boolean-esque strings, or just booleans
    • Method Detail

      • parse

        public @NonNull ArgumentParseResult<java.lang.Boolean> parse​(@NonNull CommandContext<C> commandContext,
                                                                     @NonNull java.util.Queue<@NonNull java.lang.String> inputQueue)
        Description copied from interface: ArgumentParser
        Parse command input into a command result.

        This method may be called when a command chain is being parsed for execution (using CommandManager.executeCommand(Object, String)) or when a command is being parsed to provide context for suggestions (using CommandManager.suggest(Object, String)). It is possible to use CommandContext.isSuggestions()} to see what the purpose of the parsing is. Particular care should be taken when parsing for suggestions, as the parsing method is then likely to be called once for every character written by the command sender.

        This method should never throw any exceptions under normal circumstances. Instead, if the parsing for some reason cannot be done successfully ArgumentParseResult.failure(Throwable) should be returned. This then wraps any exception that should be forwarded to the command sender.

        The parser is assumed to be completely stateless and should not store any information about the command sender or the command context. Instead, information should be stored in the CommandContext.

        Specified by:
        parse in interface ArgumentParser<C,​java.lang.Boolean>
        Parameters:
        commandContext - Command context
        inputQueue - The queue of arguments
        Returns:
        Parsed command result
      • suggestions

        public @NonNull java.util.List<@NonNull java.lang.String> suggestions​(@NonNull CommandContext<C> commandContext,
                                                                              @NonNull java.lang.String input)
        Description copied from interface: ArgumentParser
        Get a list of suggested arguments that would be correctly parsed by this parser

        This method is likely to be called for every character provided by the sender and so it may be necessary to cache results locally to prevent unnecessary computations

        Specified by:
        suggestions in interface ArgumentParser<C,​java.lang.Boolean>
        Parameters:
        commandContext - Command context
        input - Input string
        Returns:
        List of suggestions
      • isContextFree

        public boolean isContextFree()
        Description copied from interface: ArgumentParser
        Check whether or not this argument parser is context free. A context free parser will not use the provided command context, and so supports impromptu parsing
        Specified by:
        isContextFree in interface ArgumentParser<C,​java.lang.Boolean>
        Returns:
        true if the parser is context free, else false