Class NoOptionLikeValuesRestriction
java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.common.AbstractStringRestriction
com.github.rvesse.airline.restrictions.common.AbstractLocaleAndCaseStringRestriction
com.github.rvesse.airline.restrictions.common.StartsWithRestriction
com.github.rvesse.airline.restrictions.common.NoOptionLikeValuesRestriction
- All Implemented Interfaces:
HelpHint, ArgumentsRestriction, GlobalRestriction, OptionRestriction
public class NoOptionLikeValuesRestriction
extends StartsWithRestriction
implements GlobalRestriction
A restriction that enforces that values CANNOT look like options
Please see NoOptionLikeValues for more discussion of how
this restriction applies.
-
Field Summary
Fields inherited from class AbstractLocaleAndCaseStringRestriction
ignoreCase, localeFields inherited from interface GlobalRestriction
DEFAULTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]getContentBlock(int blockNumber) Gets the content block with the given numberGets the format of the provided help informationGets the preamble text that should be includedprotected booleanMethod that derived classes must implement to check whether a value is validintGets the number of content blocks provided<T> voidvalidate(ParseState<T> state) Validates the parser stateprotected <T> ParseRestrictionViolatedExceptionviolated(ParseState<T> state, ArgumentsMetadata arguments, String value) Method that derived classes must implement to provide an exception for the case of an invalid argument value, this will be called ifAbstractStringRestriction.isValid(String)returnsfalseprotected <T> ParseRestrictionViolatedExceptionviolated(ParseState<T> state, OptionMetadata option, String value) Method that derived classes must implement to provide an exception for the case of an invalid option value, this will be called ifAbstractStringRestriction.isValid(String)returnsfalseMethods inherited from class AbstractStringRestriction
preValidate, preValidateMethods inherited from class AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate
-
Constructor Details
-
NoOptionLikeValuesRestriction
-
-
Method Details
-
isValid
Description copied from class:AbstractStringRestrictionMethod that derived classes must implement to check whether a value is valid- Overrides:
isValidin classStartsWithRestriction- Parameters:
value- Value- Returns:
- True if valid, false if valid
-
violated
protected <T> ParseRestrictionViolatedException violated(ParseState<T> state, OptionMetadata option, String value) Description copied from class:AbstractStringRestrictionMethod that derived classes must implement to provide an exception for the case of an invalid option value, this will be called ifAbstractStringRestriction.isValid(String)returnsfalse- Overrides:
violatedin classStartsWithRestriction- Parameters:
state- Parser stateoption- Option metadata for the option whose value is being checkedvalue- Value which has been deemed invalid- Returns:
- Exception
-
violated
protected <T> ParseRestrictionViolatedException violated(ParseState<T> state, ArgumentsMetadata arguments, String value) Description copied from class:AbstractStringRestrictionMethod that derived classes must implement to provide an exception for the case of an invalid argument value, this will be called ifAbstractStringRestriction.isValid(String)returnsfalse- Overrides:
violatedin classStartsWithRestriction- Parameters:
state- Parser statearguments- Arguments metadatavalue- Value which has been deemed invalid- Returns:
- Exception
-
validate
Description copied from interface:GlobalRestrictionValidates the parser stateShould throw an exception if the restriction is violated, otherwise should simply return
- Specified by:
validatein interfaceGlobalRestriction- Parameters:
state- Parser state
-
getPreamble
Description copied from interface:HelpHintGets the preamble text that should be included- Specified by:
getPreamblein interfaceHelpHint- Overrides:
getPreamblein classStartsWithRestriction- Returns:
- Preamble text
-
getFormat
Description copied from interface:HelpHintGets the format of the provided help information- Specified by:
getFormatin interfaceHelpHint- Overrides:
getFormatin classStartsWithRestriction- Returns:
- Help format
-
numContentBlocks
public int numContentBlocks()Description copied from interface:HelpHintGets the number of content blocks providedHelp generators should consult the
HelpHint.getFormat()return value to determine how to format the content blocks but they are not required to do so- Specified by:
numContentBlocksin interfaceHelpHint- Overrides:
numContentBlocksin classStartsWithRestriction- Returns:
- Number of content blocks
-
getContentBlock
Description copied from interface:HelpHintGets the content block with the given number- Specified by:
getContentBlockin interfaceHelpHint- Overrides:
getContentBlockin classStartsWithRestriction- Parameters:
blockNumber- Block number- Returns:
- Content Block
-