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 class
RequiredUnlessEnvironmentRestriction.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 numberHelpFormat
getFormat()
Gets the format of the provided help informationjava.lang.String
getPreamble()
Gets the preamble text that should be includedint
numContentBlocks()
Gets the number of content blocks providedprotected <T> boolean
unless(ParseState<T> state, ArgumentsMetadata arguments)
Answers whether the unless condition of the restriction is metprotected <T> boolean
unless(ParseState<T> state, OptionMetadata option)
Answers whether the unless condition of the restriction is metprotected 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.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:AbstractRequiredUnlessRestriction
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.
- Specified by:
unless
in 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:AbstractRequiredUnlessRestriction
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.
- Specified by:
unless
in 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:AbstractRequiredUnlessRestriction
Provides a description of the unless condition, this will be included in the error messages when this restriction is not met- Specified by:
unlessDescription
in classAbstractRequiredUnlessRestriction
- Returns:
- Unless condition description
-
getPreamble
public java.lang.String getPreamble()
Description copied from interface:HelpHint
Gets the preamble text that should be included- Specified by:
getPreamble
in interfaceHelpHint
- Returns:
- Preamble text
-
getFormat
public HelpFormat getFormat()
Description copied from interface:HelpHint
Gets the format of the provided help information
-
numContentBlocks
public int numContentBlocks()
Description copied from interface:HelpHint
Gets 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:
numContentBlocks
in interfaceHelpHint
- Returns:
- Number of content blocks
-
getContentBlock
public java.lang.String[] getContentBlock(int blockNumber)
Description copied from interface:HelpHint
Gets the content block with the given number- Specified by:
getContentBlock
in interfaceHelpHint
- Parameters:
blockNumber
- Block number- Returns:
- Content Block
-
-