Module com.github.rvesse.airline
Class PathRestriction
- java.lang.Object
-
- com.github.rvesse.airline.restrictions.AbstractCommonRestriction
-
- com.github.rvesse.airline.restrictions.common.PathRestriction
-
- All Implemented Interfaces:
HelpHint
,ArgumentsRestriction
,OptionRestriction
public class PathRestriction extends AbstractCommonRestriction implements HelpHint
Implements restriction on options and arguments that expect to receive a path to a file and/or directory
-
-
Constructor Summary
Constructors Constructor Description PathRestriction(boolean mustExist, boolean readable, boolean writable, boolean executable, PathKind kind)
Creates a new path 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 includedprivate void
notExecutable(java.lang.String title, java.lang.String path)
private void
notReadable(java.lang.String title, java.lang.String path)
private void
notWritable(java.lang.String title, java.lang.String path)
int
numContentBlocks()
Gets the number of content blocks provided<T> void
preValidate(ParseState<T> state, ArgumentsMetadata arguments, java.lang.String value)
Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value<T> void
preValidate(ParseState<T> state, OptionMetadata option, java.lang.String value)
Method that is called before Airline attempts to convert a string argument received into a strongly typed Java valueprotected void
validate(java.lang.String title, java.lang.String path)
-
Methods inherited from class com.github.rvesse.airline.restrictions.AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate
-
-
-
-
Field Detail
-
mustExist
private final boolean mustExist
-
readable
private final boolean readable
-
writable
private final boolean writable
-
executable
private final boolean executable
-
kind
private final PathKind kind
-
-
Constructor Detail
-
PathRestriction
public PathRestriction(boolean mustExist, boolean readable, boolean writable, boolean executable, PathKind kind)
Creates a new path restriction- Parameters:
mustExist
- Whether the path must existreadable
- Whether the path must be readable, if the specific path does not exist then this check validates that the first parent in the path that exists is readablewritable
- Whether the path must be writable, if the specific path does not exist then this check validates that the first parent in the path that exists is writableexecutable
- Whether the path must be executable, if the specific path does not exist then this check validates that the first parent in the path that exists is executablekind
-
-
-
Method Detail
-
validate
protected void validate(java.lang.String title, java.lang.String path)
-
notExecutable
private void notExecutable(java.lang.String title, java.lang.String path)
-
notWritable
private void notWritable(java.lang.String title, java.lang.String path)
-
notReadable
private void notReadable(java.lang.String title, java.lang.String path)
-
preValidate
public <T> void preValidate(ParseState<T> state, OptionMetadata option, java.lang.String value)
Description copied from interface:OptionRestriction
Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidate
in interfaceOptionRestriction
- Overrides:
preValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser stateoption
- Option meta-datavalue
- String value
-
preValidate
public <T> void preValidate(ParseState<T> state, ArgumentsMetadata arguments, java.lang.String value)
Description copied from interface:ArgumentsRestriction
Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidate
in interfaceArgumentsRestriction
- Overrides:
preValidate
in classAbstractCommonRestriction
- Parameters:
state
- Parser statearguments
- Arguments meta-datavalue
- String 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
-
-