Module com.github.rvesse.airline
Class RangeRestriction
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.AbstractCommonRestriction
-
- com.github.rvesse.airline.restrictions.common.RangeRestriction
-
- All Implemented Interfaces:
HelpHint,ArgumentsRestriction,OptionRestriction
public class RangeRestriction extends AbstractCommonRestriction implements HelpHint
A restriction that requires the value (after type conversion) to be within a given range
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<java.lang.Object>comparatorprivate java.lang.Objectmaxprivate booleanmaxInclusiveprivate java.lang.Objectminprivate booleanminInclusiveprivate booleansingleValue
-
Constructor Summary
Constructors Constructor Description RangeRestriction(java.lang.Object min, boolean minInclusive, java.lang.Object max, boolean maxInclusive, java.util.Comparator<java.lang.Object> comparator)
-
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 includedprotected booleaninRange(java.lang.Object value)intnumContentBlocks()Gets the number of content blocks provided<T> voidpostValidate(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> voidpostValidate(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
-
min
private final java.lang.Object min
-
max
private final java.lang.Object max
-
minInclusive
private final boolean minInclusive
-
maxInclusive
private final boolean maxInclusive
-
singleValue
private final boolean singleValue
-
comparator
private final java.util.Comparator<java.lang.Object> comparator
-
-
Method Detail
-
postValidate
public <T> void postValidate(ParseState<T> state, OptionMetadata option, java.lang.Object value)
Description copied from interface:OptionRestrictionMethod that is called after Airline has converted a string argument received into a strongly typed Java value- Specified by:
postValidatein interfaceOptionRestriction- Overrides:
postValidatein 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:ArgumentsRestrictionMethod that is called after Airline has converted a string argument received into a strongly typed Java value- Specified by:
postValidatein interfaceArgumentsRestriction- Overrides:
postValidatein classAbstractCommonRestriction- Parameters:
state- Parser statearguments- Arguments meta-datavalue- Strongly typed value
-
inRange
protected boolean inRange(java.lang.Object value)
-
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
-
-