Class FloatParser<C>
- All Implemented Interfaces:
ArgumentParser<C,,Float> SuggestionProviderHolder<C>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.incendo.cloud.parser.ArgumentParser
ArgumentParser.FutureArgumentParser<C,T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final floatConstant for the default/unset maximum value.static final floatConstant for the default/unset minimum value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <C> @NonNull CommandComponent.Builder<C, Float> Returns aCommandComponent.BuilderusingfloatParser()as the parser.static <C> @NonNull ParserDescriptor<C, Float> Creates a new float parser usingDEFAULT_MINIMUMandDEFAULT_MAXIMUMas the limits.static <C> @NonNull ParserDescriptor<C, Float> floatParser(float minValue) Creates a new float parser usingDEFAULT_MAXIMUMas the maximum value.static <C> @NonNull ParserDescriptor<C, Float> floatParser(float minValue, float maxValue) Creates a new float parser.booleanhasMax()Returns whether this parser has a maximum value set.booleanhasMin()Returns whether this parser has a minimum value set.parse(@NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Attempts to parse theinputinto an object of typeArgumentParser.Methods inherited from class org.incendo.cloud.parser.standard.NumberParser
rangeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.incendo.cloud.parser.ArgumentParser
flatMap, flatMapSuccess, mapSuccess, parseFuture, suggestionProvider
-
Field Details
-
DEFAULT_MINIMUM
Constant for the default/unset minimum value.- See Also:
-
DEFAULT_MAXIMUM
Constant for the default/unset maximum value.- See Also:
-
-
Constructor Details
-
FloatParser
public FloatParser(float min, float max) Construct a new float parser- Parameters:
min- Minimum acceptable valuemax- Maximum acceptable value
-
-
Method Details
-
floatParser
Creates a new float parser usingDEFAULT_MINIMUMandDEFAULT_MAXIMUMas the limits.- Type Parameters:
C- the command sender type- Returns:
- the created parser
-
floatParser
@API(status=STABLE) public static <C> @NonNull ParserDescriptor<C,Float> floatParser(float minValue) Creates a new float parser usingDEFAULT_MAXIMUMas the maximum value.- Type Parameters:
C- the command sender type- Parameters:
minValue- the minimum value accepted by the parser- Returns:
- the created parser
-
floatParser
@API(status=STABLE) public static <C> @NonNull ParserDescriptor<C,Float> floatParser(float minValue, float maxValue) Creates a new float parser.- Type Parameters:
C- the command sender type- Parameters:
minValue- the minimum value accepted by the parsermaxValue- the maximum value accepted by the parser- Returns:
- the created parser
-
floatComponent
Returns aCommandComponent.BuilderusingfloatParser()as the parser.- Type Parameters:
C- the command sender type- Returns:
- the component builder
-
parse
public @NonNull ArgumentParseResult<Float> parse(@NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Description copied from interface:ArgumentParserAttempts to parse theinputinto an object of typeArgumentParser.This method may be called when a command chain is being parsed for execution (using
CommandExecutor.executeCommand(Object, String)) or when a command is being parsed to provide context for suggestions (usingSuggestionFactory.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.- Parameters:
commandContext- Command contextcommandInput- Command Input- Returns:
- Parsed command result
-
hasMax
public boolean hasMax()Description copied from class:NumberParserReturns whether this parser has a maximum value set.In other words, whether the
maximumof it'sNumberParser.range()is different than the default maximum value.- Specified by:
hasMaxin classNumberParser<C,Float, FloatRange> - Returns:
- whether the parser has a maximum set
-
hasMin
public boolean hasMin()Description copied from class:NumberParserReturns whether this parser has a minimum value set.In other words, whether the
minimumof it'sNumberParser.range()is different than the default minimum value.- Specified by:
hasMinin classNumberParser<C,Float, FloatRange> - Returns:
- whether the parser has a minimum set
-