Module com.github.rvesse.airline
Class PositiveNegativeRestriction
java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.common.PositiveNegativeRestriction
- All Implemented Interfaces:
HelpHint
,ArgumentsRestriction
,OptionRestriction
Restriction that enforces that values must be either positive/negative with
zero optionally included
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RangeRestriction
private final RangeRestriction
private final RangeRestriction
private final boolean
private final RangeRestriction
private final RangeRestriction
private final boolean
private final String
private final RangeRestriction
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionPositiveNegativeRestriction
(boolean positive, boolean includeZero) Creates a new restriction -
Method Summary
Modifier and TypeMethodDescriptionString[]
getContentBlock
(int blockNumber) Gets the content block with the given numberGets the format of the provided help informationGets the preamble text that should be includedprotected boolean
int
Gets the number of content blocks provided<T> void
postValidate
(ParseState<T> state, ArgumentsMetadata arguments, Object value) Method that is called after Airline has converted a string argument received into a strongly typed Java value<T> void
postValidate
(ParseState<T> state, OptionMetadata option, Object value) Method that is called after Airline has converted a string argument received into a strongly typed Java valueMethods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, preValidate, preValidate
-
Field Details
-
byteRestrictor
-
shortRestrictor
-
integerRestrictor
-
longRestrictor
-
floatRestrictor
-
doubleRestrictor
-
positive
private final boolean positive -
includeZero
private final boolean includeZero -
type
-
range
-
-
Constructor Details
-
PositiveNegativeRestriction
public PositiveNegativeRestriction(boolean positive, boolean includeZero) Creates a new restriction- Parameters:
positive
- Whether the value must be positiveincludeZero
- Whether zero is included as a valid value
-
-
Method Details
-
isValid
-
postValidate
Description copied from interface:OptionRestriction
Method that is called after Airline has converted a string argument received into a strongly typed Java value- Specified by:
postValidate
in interfaceOptionRestriction
- Overrides:
postValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser stateoption
- Option meta-datavalue
- Strongly typed value
-
postValidate
Description copied from interface:ArgumentsRestriction
Method that is called after Airline has converted a string argument received into a strongly typed Java value- Specified by:
postValidate
in interfaceArgumentsRestriction
- Overrides:
postValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser statearguments
- Arguments meta-datavalue
- Strongly typed value
-
getPreamble
Description copied from interface:HelpHint
Gets the preamble text that should be included- Specified by:
getPreamble
in interfaceHelpHint
- Returns:
- Preamble text
-
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
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
-