Class LongArgument.LongParser<C>
- All Implemented Interfaces:
ArgumentParser<C,Long>
- Enclosing class:
- LongArgument<C>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longConstant for the default/unset maximum value.static final longConstant for the default/unset minimum value.Fields inherited from interface cloud.commandframework.arguments.parser.ArgumentParser
DEFAULT_ARGUMENT_COUNT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetMax()Get the maximum value accepted by this parserlonggetMin()Get the minimum value accepted by this parserbooleanhasMax()Get whether this parser has a maximum set.booleanhasMin()Get whether this parser has a minimum set.booleanCheck whether this argument parser is context free.@NonNull ArgumentParseResult<Long>parse(@NonNull CommandContext<C> commandContext, @NonNull Queue<@NonNull String> inputQueue) Parse command input into a command result.suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) Get a list of suggested arguments that would be correctly parsed by this parserMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cloud.commandframework.arguments.parser.ArgumentParser
getRequestedArgumentCount, map
-
Field Details
-
DEFAULT_MINIMUM
@API(status=STABLE, since="1.5.0") public static final long DEFAULT_MINIMUMConstant for the default/unset minimum value.- Since:
- 1.5.0
- See Also:
-
DEFAULT_MAXIMUM
@API(status=STABLE, since="1.5.0") public static final long DEFAULT_MAXIMUMConstant for the default/unset maximum value.- Since:
- 1.5.0
- See Also:
-
-
Constructor Details
-
LongParser
public LongParser(long min, long max) Construct a new long parser- Parameters:
min- Minimum acceptable valuemax- Maximum acceptable value
-
-
Method Details
-
parse
public @NonNull ArgumentParseResult<Long> parse(@NonNull CommandContext<C> commandContext, @NonNull Queue<@NonNull String> inputQueue) Description copied from interface:ArgumentParserParse 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 (usingCommandManager.suggest(Object, String)). It is possible to useCommandContext.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:
parsein interfaceArgumentParser<C,Long> - Parameters:
commandContext- Command contextinputQueue- The queue of arguments- Returns:
- Parsed command result
-
getMin
public long getMin()Get the minimum value accepted by this parser- Returns:
- Min value
-
getMax
public long getMax()Get the maximum value accepted by this parser- Returns:
- Max value
-
hasMax
@API(status=STABLE, since="1.5.0") public boolean hasMax()Get whether this parser has a maximum set. This will compare the parser's maximum toDEFAULT_MAXIMUM.- Returns:
- whether the parser has a maximum set
- Since:
- 1.5.0
-
hasMin
@API(status=STABLE, since="1.5.0") public boolean hasMin()Get whether this parser has a minimum set. This will compare the parser's minimum toDEFAULT_MINIMUM.- Returns:
- whether the parser has a maximum set
- Since:
- 1.5.0
-
isContextFree
public boolean isContextFree()Description copied from interface:ArgumentParserCheck whether this argument parser is context free. A context free parser will not use the provided command context, and so supports impromptu parsing- Specified by:
isContextFreein interfaceArgumentParser<C,Long> - Returns:
trueif the parser is context free, elsefalse
-
suggestions
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) Description copied from interface:ArgumentParserGet a list of suggested arguments that would be correctly parsed by this parserThis 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:
suggestionsin interfaceArgumentParser<C,Long> - Parameters:
commandContext- Command contextinput- Input string- Returns:
- List of suggestions
-