Module com.github.rvesse.airline
Class RequiredUnlessEnvironmentRestriction
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.AbstractCommonRestriction
-
- com.github.rvesse.airline.restrictions.options.AbstractRequiredUnlessRestriction
-
- com.github.rvesse.airline.restrictions.options.RequiredUnlessEnvironmentRestriction
-
- All Implemented Interfaces:
HelpHint,ArgumentsRestriction,OptionRestriction
public class RequiredUnlessEnvironmentRestriction extends AbstractRequiredUnlessRestriction implements HelpHint
A restriction that requires an option/argument be set UNLESS a suitable environment variable is specified.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classRequiredUnlessEnvironmentRestriction.IsEnvVarSet
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>variables
-
Constructor Summary
Constructors Constructor Description RequiredUnlessEnvironmentRestriction(java.lang.String[] envVars)
-
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 includedintnumContentBlocks()Gets the number of content blocks providedprotected <T> booleanunless(ParseState<T> state, ArgumentsMetadata arguments)Answers whether the unless condition of the restriction is metprotected <T> booleanunless(ParseState<T> state, OptionMetadata option)Answers whether the unless condition of the restriction is metprotected java.lang.StringunlessDescription()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.options.AbstractRequiredUnlessRestriction
finalValidate, finalValidate
-
Methods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate, preValidate, preValidate
-
-
-
-
Method Detail
-
unless
protected <T> boolean unless(ParseState<T> state, OptionMetadata option)
Description copied from class:AbstractRequiredUnlessRestrictionAnswers 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.
- Specified by:
unlessin classAbstractRequiredUnlessRestriction- Type Parameters:
T- Command Type- Parameters:
state- Parse stateoption- Option Metadata- Returns:
- True if unless condition met, false otherwise
-
unless
protected <T> boolean unless(ParseState<T> state, ArgumentsMetadata arguments)
Description copied from class:AbstractRequiredUnlessRestrictionAnswers whether the unless condition of the restriction is metIf the unless condition is met then the restriction will not require arguments to be present.
- Specified by:
unlessin classAbstractRequiredUnlessRestriction- Type Parameters:
T- Command Type- Parameters:
state- Parse statearguments- Arguments Metadata- Returns:
- True if unless condition met, false otherwise
-
unlessDescription
protected java.lang.String unlessDescription()
Description copied from class:AbstractRequiredUnlessRestrictionProvides a description of the unless condition, this will be included in the error messages when this restriction is not met- Specified by:
unlessDescriptionin classAbstractRequiredUnlessRestriction- Returns:
- Unless condition description
-
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
-
-