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
public class PositiveNegativeRestriction extends AbstractCommonRestriction implements HelpHint
Restriction that enforces that values must be either positive/negative with zero optionally included
-
-
Field Summary
Fields Modifier and Type Field Description private RangeRestriction
byteRestrictor
private RangeRestriction
doubleRestrictor
private RangeRestriction
floatRestrictor
private boolean
includeZero
private RangeRestriction
integerRestrictor
private RangeRestriction
longRestrictor
private boolean
positive
private java.lang.String
range
private RangeRestriction
shortRestrictor
private java.lang.String
type
-
Constructor Summary
Constructors Constructor Description PositiveNegativeRestriction(boolean positive, boolean includeZero)
Creates a new restriction
-
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 includedprotected boolean
isValid(java.lang.Object value)
int
numContentBlocks()
Gets the number of content blocks provided<T> void
postValidate(ParseState<T> state, ArgumentsMetadata arguments, java.lang.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, java.lang.Object value)
Method that is called after Airline has converted a string argument received into a strongly typed Java value-
Methods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, preValidate, preValidate
-
-
-
-
Field Detail
-
byteRestrictor
private final RangeRestriction byteRestrictor
-
shortRestrictor
private final RangeRestriction shortRestrictor
-
integerRestrictor
private final RangeRestriction integerRestrictor
-
longRestrictor
private final RangeRestriction longRestrictor
-
floatRestrictor
private final RangeRestriction floatRestrictor
-
doubleRestrictor
private final RangeRestriction doubleRestrictor
-
positive
private final boolean positive
-
includeZero
private final boolean includeZero
-
type
private final java.lang.String type
-
range
private final java.lang.String range
-
-
Method Detail
-
isValid
protected boolean isValid(java.lang.Object value)
-
postValidate
public <T> void postValidate(ParseState<T> state, OptionMetadata option, java.lang.Object value)
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
public <T> void postValidate(ParseState<T> state, ArgumentsMetadata arguments, java.lang.Object value)
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
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
-
-