Package net.apartium.cocoabeans.commands
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<?>>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class net.apartium.cocoabeans.commands.parsers.ArgumentParser
ArgumentParser.ParseResult<T>, ArgumentParser.TabCompletionResult -
Constructor Summary
ConstructorsConstructorDescriptionRegisterArgumentParser(ArgumentParser<T> parser, boolean optionalNotMatch, boolean isOptional, String parameterName) A constructor for a register argument parser -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the parameter nameinthashCode()booleanGet if the argument parser accept no argumentbooleanGet if the argument parser accept optional but does not matchparse(CommandProcessingContext processingContext) Tries to parse next argument in the contextparser()Get the argument parser that this register argument parser wrapstabCompletion(CommandProcessingContext processingContext) Retrieves available options for tab completion of this argumenttryParse(CommandProcessingContext processingContext) Tries to lazily parse next argument in the contextMethods inherited from class net.apartium.cocoabeans.commands.parsers.ArgumentParser
compareTo, getArgumentType, getKeyword, getPriority
-
Constructor Details
-
RegisterArgumentParser
public RegisterArgumentParser(ArgumentParser<T> parser, boolean optionalNotMatch, boolean isOptional, String parameterName) A constructor for a register argument parser- Parameters:
parser- argument parseroptionalNotMatch- return optional if not match the parserisOptional- could we don't use the parser and return optionalparameterName- parameter name will be used for better parameter control
-
-
Method Details
-
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
Get the parameter name- Returns:
- the parameter name
-
parse
Tries to parse next argument in the context- Specified by:
parsein classArgumentParser<T>- Parameters:
processingContext- cmd processing context- Returns:
- empty if failed, otherwise result
-
tryParse
Tries to lazily parse next argument in the context- Specified by:
tryParsein classArgumentParser<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:
tabCompletionin classArgumentParser<T>- Parameters:
processingContext- cmd processing context- Returns:
- tab completion result if success, otherwise empty option
-
equals
-
hashCode
public int hashCode()
-