Module com.github.rvesse.airline
Class AbstractRequiredUnlessRestriction
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.AbstractCommonRestriction
-
- com.github.rvesse.airline.restrictions.options.AbstractRequiredUnlessRestriction
-
- All Implemented Interfaces:
ArgumentsRestriction
,OptionRestriction
- Direct Known Subclasses:
RequiredUnlessEnvironmentRestriction
public abstract class AbstractRequiredUnlessRestriction extends AbstractCommonRestriction
A restriction that options/arguments are required unless some other criteria is met
-
-
Constructor Summary
Constructors Constructor Description AbstractRequiredUnlessRestriction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> void
finalValidate(ParseState<T> state, ArgumentsMetadata arguments)
Method that is called after Airline has completed parsing<T> void
finalValidate(ParseState<T> state, OptionMetadata option)
Method that is called after Airline has completed parsingprotected abstract <T> boolean
unless(ParseState<T> state, ArgumentsMetadata arguments)
Answers whether the unless condition of the restriction is metprotected abstract <T> boolean
unless(ParseState<T> state, OptionMetadata option)
Answers whether the unless condition of the restriction is metprotected abstract java.lang.String
unlessDescription()
Provides a description of the unless condition, this will be included in the error messages when this restriction is not met-
Methods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate, preValidate, preValidate
-
-
-
-
Method Detail
-
unless
protected abstract <T> boolean unless(ParseState<T> state, OptionMetadata option)
Answers whether the unless condition of the restriction is metIf the unless condition is met then the restriction will not require the option to be present.
- Type Parameters:
T
- Command Type- Parameters:
state
- Parse stateoption
- Option Metadata- Returns:
- True if unless condition met, false otherwise
-
unless
protected abstract <T> boolean unless(ParseState<T> state, ArgumentsMetadata arguments)
Answers whether the unless condition of the restriction is metIf the unless condition is met then the restriction will not require arguments to be present.
- Type Parameters:
T
- Command Type- Parameters:
state
- Parse statearguments
- Arguments Metadata- Returns:
- True if unless condition met, false otherwise
-
unlessDescription
protected abstract java.lang.String unlessDescription()
Provides a description of the unless condition, this will be included in the error messages when this restriction is not met- Returns:
- Unless condition description
-
finalValidate
public <T> void finalValidate(ParseState<T> state, OptionMetadata option)
Description copied from interface:OptionRestriction
Method that is called after Airline has completed parsingThis can be used to implement restrictions that require the final parser state to process
- Specified by:
finalValidate
in interfaceOptionRestriction
- Overrides:
finalValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser stateoption
- Option meta-data
-
finalValidate
public <T> void finalValidate(ParseState<T> state, ArgumentsMetadata arguments)
Description copied from interface:ArgumentsRestriction
Method that is called after Airline has completed parsingThis can be used to implement restrictions that require the final parser state to process
- Specified by:
finalValidate
in interfaceArgumentsRestriction
- Overrides:
finalValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser statearguments
- Arguments meta-data
-
-