Class AbstractStringRestriction
java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.common.AbstractStringRestriction
- All Implemented Interfaces:
ArgumentsRestriction, OptionRestriction
- Direct Known Subclasses:
AbstractLocaleAndCaseStringRestriction, LengthRestriction, NotBlankRestriction, NotEmptyRestriction
Abstract restrictions on string values for options and arguments
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanMethod that derived classes must implement to check whether a value is validfinal <T> voidpreValidate(ParseState<T> state, ArgumentsMetadata arguments, String value) Method that is called before Airline attempts to convert a string argument received into a strongly typed Java valuefinal <T> voidpreValidate(ParseState<T> state, OptionMetadata option, String value) Method that is called before Airline attempts to convert a string argument received into a strongly typed Java valueprotected abstract <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 ifisValid(String)returnsfalseprotected abstract <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 ifisValid(String)returnsfalseMethods inherited from class AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate
-
Constructor Details
-
AbstractStringRestriction
public AbstractStringRestriction()
-
-
Method Details
-
preValidate
Description copied from interface:OptionRestrictionMethod that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidatein interfaceOptionRestriction- Overrides:
preValidatein classAbstractCommonRestriction- Parameters:
state- Parser stateoption- Option meta-datavalue- String value
-
preValidate
Description copied from interface:ArgumentsRestrictionMethod that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidatein interfaceArgumentsRestriction- Overrides:
preValidatein classAbstractCommonRestriction- Parameters:
state- Parser statearguments- Arguments meta-datavalue- String value
-
isValid
Method that derived classes must implement to check whether a value is valid- Parameters:
value- Value- Returns:
- True if valid, false if valid
-
violated
protected abstract <T> ParseRestrictionViolatedException violated(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 ifisValid(String)returnsfalse- Parameters:
state- Parser stateoption- Option metadata for the option whose value is being checkedvalue- Value which has been deemed invalid- Returns:
- Exception
-
violated
protected abstract <T> ParseRestrictionViolatedException violated(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 ifisValid(String)returnsfalse- Parameters:
state- Parser statearguments- Arguments metadatavalue- Value which has been deemed invalid- Returns:
- Exception
-