Module com.github.rvesse.airline
Class EndsWithRestriction
- 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.EndsWithRestriction
-
- All Implemented Interfaces:
HelpHint,ArgumentsRestriction,OptionRestriction
public class EndsWithRestriction extends AbstractLocaleAndCaseStringRestriction implements HelpHint
A restriction that requires raw values to end with one of a set of suffixes
-
-
Field Summary
Fields Modifier and Type Field Description private SuffixMatchermatcherprivate java.lang.String[]suffixes-
Fields inherited from class com.github.rvesse.airline.restrictions.common.AbstractLocaleAndCaseStringRestriction
ignoreCase, locale
-
-
Constructor Summary
Constructors Constructor Description EndsWithRestriction(boolean ignoreCase, java.util.Locale locale, java.lang.String... suffixes)
-
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 numberHelpFormatgetFormat()Gets the format of the provided help informationjava.lang.StringgetPreamble()Gets the preamble text that should be includedprotected booleanisValid(java.lang.String value)Method that derived classes must implement to check whether a value is validintnumContentBlocks()Gets the number of content blocks providedprotected <T> ParseRestrictionViolatedExceptionviolated(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)returnsfalseprotected <T> ParseRestrictionViolatedExceptionviolated(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
-
-
-
-
Field Detail
-
suffixes
private final java.lang.String[] suffixes
-
matcher
private final SuffixMatcher matcher
-
-
Method Detail
-
isValid
protected boolean isValid(java.lang.String value)
Description copied from class:AbstractStringRestrictionMethod that derived classes must implement to check whether a value is valid- Specified by:
isValidin classAbstractStringRestriction- 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: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- Specified by:
violatedin classAbstractStringRestriction- 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: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- Specified by:
violatedin classAbstractStringRestriction- Parameters:
state- Parser statearguments- Arguments metadatavalue- Value which has been deemed invalid- Returns:
- Exception
-
getPreamble
public java.lang.String getPreamble()
Description copied from interface:HelpHintGets the preamble text that should be included- Specified by:
getPreamblein interfaceHelpHint- Returns:
- Preamble text
-
getFormat
public HelpFormat getFormat()
Description copied from interface:HelpHintGets the format of the provided help information
-
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- Returns:
- Number of content blocks
-
getContentBlock
public java.lang.String[] getContentBlock(int blockNumber)
Description copied from interface:HelpHintGets the content block with the given number- Specified by:
getContentBlockin interfaceHelpHint- Parameters:
blockNumber- Block number- Returns:
- Content Block
-
-