Module com.github.rvesse.airline
Class PortRestriction
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.AbstractCommonRestriction
-
- com.github.rvesse.airline.restrictions.common.PortRestriction
-
- All Implemented Interfaces:
HelpHint
,ArgumentsRestriction
,OptionRestriction
public class PortRestriction extends AbstractCommonRestriction implements HelpHint
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<PortRange>
acceptablePorts
private static int
MAX_PORT
private static int
MIN_PORT
-
Constructor Summary
Constructors Constructor Description PortRestriction(PortRange... portRanges)
-
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
inAnyAcceptableRange(int port)
protected void
invalidArgumentsPort(ArgumentsMetadata arguments, java.lang.String title, java.lang.Object value)
protected void
invalidOptionPort(OptionMetadata option, java.lang.String title, java.lang.Object value)
protected void
invalidPort(java.lang.String title, java.lang.Object value)
private boolean
isValid(int port)
private boolean
isValid(long port)
private boolean
isValid(short port)
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
-
MIN_PORT
private static final int MIN_PORT
- See Also:
- Constant Field Values
-
MAX_PORT
private static final int MAX_PORT
- See Also:
- Constant Field Values
-
acceptablePorts
private java.util.Set<PortRange> acceptablePorts
-
-
Constructor Detail
-
PortRestriction
public PortRestriction(PortRange... portRanges)
-
-
Method Detail
-
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
-
invalidOptionPort
protected void invalidOptionPort(OptionMetadata option, java.lang.String title, java.lang.Object value)
-
invalidArgumentsPort
protected void invalidArgumentsPort(ArgumentsMetadata arguments, java.lang.String title, java.lang.Object value)
-
invalidPort
protected void invalidPort(java.lang.String title, java.lang.Object 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
-
isValid
private boolean isValid(long port)
-
isValid
private boolean isValid(int port)
-
isValid
private boolean isValid(short port)
-
inAnyAcceptableRange
protected boolean inAnyAcceptableRange(int port)
-
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
-
-