Module com.github.rvesse.airline
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 optionsPlease see
NoOptionLikeValues
for more discussion of how this restriction applies.
-
-
Field Summary
-
Fields inherited from class com.github.rvesse.airline.restrictions.common.AbstractLocaleAndCaseStringRestriction
ignoreCase, locale
-
Fields inherited from interface com.github.rvesse.airline.restrictions.GlobalRestriction
DEFAULTS
-
-
Constructor Summary
Constructors Constructor Description NoOptionLikeValuesRestriction(java.lang.String[] prefixes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
getContentBlock(int blockNumber)
Gets the content block with the given numberHelpFormat
getFormat()
Gets the format of the provided help informationjava.lang.String
getPreamble()
Gets the preamble text that should be includedprotected boolean
isValid(java.lang.String value)
Method that derived classes must implement to check whether a value is validint
numContentBlocks()
Gets the number of content blocks provided<T> void
validate(ParseState<T> state)
Validates the parser stateprotected <T> ParseRestrictionViolatedException
violated(ParseState<T> state, ArgumentsMetadata arguments, java.lang.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)
returnsfalse
protected <T> ParseRestrictionViolatedException
violated(ParseState<T> state, OptionMetadata option, java.lang.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)
returnsfalse
-
Methods inherited from class com.github.rvesse.airline.restrictions.common.AbstractStringRestriction
preValidate, preValidate
-
Methods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate
-
-
-
-
Method Detail
-
isValid
protected boolean isValid(java.lang.String value)
Description copied from class:AbstractStringRestriction
Method that derived classes must implement to check whether a value is valid- Overrides:
isValid
in classStartsWithRestriction
- Parameters:
value
- Value- Returns:
- True if valid, false if valid
-
violated
protected <T> ParseRestrictionViolatedException violated(ParseState<T> state, OptionMetadata option, java.lang.String value)
Description copied from class:AbstractStringRestriction
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)
returnsfalse
- Overrides:
violated
in 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, java.lang.String value)
Description copied from class:AbstractStringRestriction
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)
returnsfalse
- Overrides:
violated
in classStartsWithRestriction
- Parameters:
state
- Parser statearguments
- Arguments metadatavalue
- Value which has been deemed invalid- Returns:
- Exception
-
validate
public <T> void validate(ParseState<T> state)
Description copied from interface:GlobalRestriction
Validates the parser stateShould throw an exception if the restriction is violated, otherwise should simply return
- Specified by:
validate
in interfaceGlobalRestriction
- Parameters:
state
- Parser state
-
getPreamble
public java.lang.String getPreamble()
Description copied from interface:HelpHint
Gets the preamble text that should be included- Specified by:
getPreamble
in interfaceHelpHint
- Overrides:
getPreamble
in classStartsWithRestriction
- Returns:
- Preamble text
-
getFormat
public HelpFormat getFormat()
Description copied from interface:HelpHint
Gets the format of the provided help information- Specified by:
getFormat
in interfaceHelpHint
- Overrides:
getFormat
in classStartsWithRestriction
- Returns:
- Help format
-
numContentBlocks
public int numContentBlocks()
Description copied from interface:HelpHint
Gets 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:
numContentBlocks
in interfaceHelpHint
- Overrides:
numContentBlocks
in classStartsWithRestriction
- Returns:
- Number of content blocks
-
getContentBlock
public java.lang.String[] getContentBlock(int blockNumber)
Description copied from interface:HelpHint
Gets the content block with the given number- Specified by:
getContentBlock
in interfaceHelpHint
- Overrides:
getContentBlock
in classStartsWithRestriction
- Parameters:
blockNumber
- Block number- Returns:
- Content Block
-
-