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
A restriction that options/arguments are required unless some other criteria is met
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<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 String
Provides a description of the unless condition, this will be included in the error messages when this restriction is not metMethods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate, preValidate, preValidate
-
Constructor Details
-
AbstractRequiredUnlessRestriction
public AbstractRequiredUnlessRestriction()
-
-
Method Details
-
unless
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
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
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
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
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
-