Class DirectoryOption
java.lang.Object
eu.svjatoslav.commons.cli_helper.parameter_parser.Option<File,DirectoryOption>
eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.DirectoryOption
Represents a command-line option that accepts exactly one parameter interpreted as a directory path.
-
Field Summary
Fields inherited from class eu.svjatoslav.commons.cli_helper.parameter_parser.Option
description, mandatory, parameters
-
Constructor Summary
ConstructorsConstructorDescriptionDirectoryOption
(String description) Creates a DirectoryOption object with a specified description. -
Method Summary
Modifier and TypeMethodDescriptionDescribes the kind or format of the expected parameter(s), e.g.getValue()
Returns the directory as aFile
object.boolean
Checks whether the provided path is valid based on theExistenceType
.Requires that the directory must already exist.Requires that the directory must not already exist.Methods inherited from class eu.svjatoslav.commons.cli_helper.parameter_parser.Option
addAliases, addParameter, getAliasesAsString, getHelp, isMandatory, isPresent, matchesAlias, noMoreArguments, setMandatory, setPresent
-
Constructor Details
-
DirectoryOption
Creates a DirectoryOption object with a specified description.- Parameters:
description
- a brief description of what this directory option is for.
-
-
Method Details
-
describeFormat
Description copied from class:Option
Describes the kind or format of the expected parameter(s), e.g. "File", "Integer", etc.- Specified by:
describeFormat
in classOption<File,
DirectoryOption> - Returns:
- a short string describing the parameter format
-
getValue
Returns the directory as aFile
object.- Specified by:
getValue
in classOption<File,
DirectoryOption> - Returns:
- the parsed value as the generic type T.
- Throws:
RuntimeException
- if the user did not provide exactly one parameter.
-
mustExist
Requires that the directory must already exist.- Returns:
- this DirectoryOption instance for chaining
-
mustNotExist
Requires that the directory must not already exist.- Returns:
- this DirectoryOption instance for chaining
-
isValid
Checks whether the provided path is valid based on theExistenceType
.- Specified by:
isValid
in classOption<File,
DirectoryOption> - Parameters:
value
- the directory path to validate- Returns:
true
if valid, otherwisefalse
-