Class PathRestriction
java.lang.Object
com.github.rvesse.airline.restrictions.AbstractCommonRestriction
com.github.rvesse.airline.restrictions.common.PathRestriction
- All Implemented Interfaces:
HelpHint, ArgumentsRestriction, OptionRestriction
Implements restriction on options and arguments that expect to receive a path
to a file and/or directory
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPathRestriction(boolean mustExist, boolean readable, boolean writable, boolean executable, PathKind kind) Creates a new path 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 includedprivate voidnotExecutable(String title, String path) private voidnotReadable(String title, String path) private voidnotWritable(String title, String path) intGets the number of content blocks provided<T> voidpreValidate(ParseState<T> state, ArgumentsMetadata arguments, String value) Method that is called before Airline attempts to convert a string argument received into a strongly typed Java value<T> voidpreValidate(ParseState<T> state, OptionMetadata option, String value) Method that is called before Airline attempts to convert a string argument received into a strongly typed Java valueprotected voidMethods inherited from class AbstractCommonRestriction
finalValidate, finalValidate, getArgumentTitle, getArgumentTitle, getOptionTitle, postValidate, postValidate
-
Field Details
-
mustExist
private final boolean mustExist -
readable
private final boolean readable -
writable
private final boolean writable -
executable
private final boolean executable -
kind
-
-
Constructor Details
-
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 Details
-
validate
-
notExecutable
-
notWritable
-
notReadable
-
preValidate
Description copied from interface:OptionRestrictionMethod that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidatein interfaceOptionRestriction- Overrides:
preValidatein classAbstractCommonRestriction- Parameters:
state- Parser stateoption- Option meta-datavalue- String value
-
preValidate
Description copied from interface:ArgumentsRestrictionMethod that is called before Airline attempts to convert a string argument received into a strongly typed Java value- Specified by:
preValidatein interfaceArgumentsRestriction- Overrides:
preValidatein classAbstractCommonRestriction- Parameters:
state- Parser statearguments- Arguments meta-datavalue- String value
-
getPreamble
Description copied from interface:HelpHintGets the preamble text that should be included- Specified by:
getPreamblein interfaceHelpHint- Returns:
- Preamble text
-
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
Description copied from interface:HelpHintGets the content block with the given number- Specified by:
getContentBlockin interfaceHelpHint- Parameters:
blockNumber- Block number- Returns:
- Content Block
-