Class Argument.ArgumentBuilder<T>
java.lang.Object
com.clumd.projects.java_common_utils.arg_parser.Argument.ArgumentBuilder<T>
-
Method Summary
Modifier and TypeMethodDescriptionargumentResult(T argumentResult) If this argument needs a value, then this should be the fully validated and parsed output of that value.build()conversionFunction(Function<String, T> conversionFunction) This function is used to convert an argument from the CLI string form, into the object the running process needs.defaultValue(T toValue) Used to set the default value, and also mark that the default value has been set.defaultValueSet(boolean defaultValueSet) Used to track if a default value has been set for this argument to be used if no CLI value is found.description(String description) Used to describe the purpose of this Argument and how it should be used.hasValue(boolean hasValue) Used to indicate if this argument can be followed by a value, defaults to falseisMandatory(boolean isMandatory) Used to indicate if this argument is mandatory and MUST be provided for the utilising code to function.longOptions(Set<String> longOptions) Used to contain all the word alias' to indicate this optionshortOptions(Set<Character> shortOptions) Used to contain all the single character alias' to indicate this optiontoString()uniqueId(int uniqueId) Used to index the options, must be unique and supplied by the user.validationFunction(Function<T, Boolean> validationFunction) This function can be provided to run a verification step that the argument's value is acceptable.valueIsOptional(boolean valueIsOptional) Used to indicate if the value to this argument can be optional, defaults to false.
-
Method Details
-
defaultValue
Used to set the default value, and also mark that the default value has been set. This can be used to notify a local Arg Parser that a local value exists, in case it wants to display this in help text.- Parameters:
toValue- The value to use as a default value for this argument.
-
uniqueId
Used to index the options, must be unique and supplied by the user.- Returns:
this.
-
shortOptions
Used to contain all the single character alias' to indicate this option- Returns:
this.
-
longOptions
Used to contain all the word alias' to indicate this option- Returns:
this.
-
isMandatory
Used to indicate if this argument is mandatory and MUST be provided for the utilising code to function. If you set this value to true, you probably don't want to set a default value.- Returns:
this.
-
hasValue
Used to indicate if this argument can be followed by a value, defaults to false- Returns:
this.
-
valueIsOptional
Used to indicate if the value to this argument can be optional, defaults to false. (e.g. value MUST be provided)- Returns:
this.
-
description
Used to describe the purpose of this Argument and how it should be used.- Returns:
this.
-
validationFunction
This function can be provided to run a verification step that the argument's value is acceptable.- Returns:
this.
-
conversionFunction
This function is used to convert an argument from the CLI string form, into the object the running process needs.- Returns:
this.
-
defaultValueSet
Used to track if a default value has been set for this argument to be used if no CLI value is found.- Returns:
this.
-
argumentResult
If this argument needs a value, then this should be the fully validated and parsed output of that value.- Returns:
this.
-
build
-
toString
-