X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=cli-helper.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcli_helper%2Fparameter_parser%2FOption.java;fp=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fcli_helper%2Fparameter_parser%2FOption.java;h=d5916638c8c80b7d8053bc238f6f189299419568;hp=9bcea3f1380f27acbfcfa75633a543f12521acc9;hb=b4b3152b0012f4e0b0b5d3e98cc8a7e4a12e8c18;hpb=e8f029969d48634280dc5ad9d9c43ba4c0699cd9 diff --git a/src/main/java/eu/svjatoslav/commons/cli_helper/parameter_parser/Option.java b/src/main/java/eu/svjatoslav/commons/cli_helper/parameter_parser/Option.java index 9bcea3f..d591663 100755 --- a/src/main/java/eu/svjatoslav/commons/cli_helper/parameter_parser/Option.java +++ b/src/main/java/eu/svjatoslav/commons/cli_helper/parameter_parser/Option.java @@ -12,6 +12,14 @@ import static java.lang.String.join; import static java.util.Collections.addAll; import static java.util.stream.Collectors.joining; +/** + * Represents an option that can be provided on CLI. + * This class allows specifying whether the option is mandatory, + * the parameter count, a description, and any aliases for the option. + * + * @param type of value that this option returns. + * @param type of this option. + */ public abstract class Option { /** @@ -43,6 +51,16 @@ public abstract class Option { */ private boolean isPresent; + /** + * Represents an option that can be provided on CLI. + * This class allows specifying whether the option is mandatory, + * the parameter count, a description, and any aliases for the option. + * + * @param mandatory indicates whether the option is mandatory + * @param parameterCount the number of parameters required for the option + * @param description a description of the option + * @param aliases2 any additional aliases for the option + */ public Option(final boolean mandatory, final ParameterCount parameterCount, final String description, final String... aliases2) { @@ -60,6 +78,12 @@ public abstract class Option { this.parameterCount = parameterCount; } + /** + * Adds additional aliases to the option. + * + * @param aliasArray an array of strings representing the aliases to be added + * @return the modified option object + */ @SuppressWarnings("unchecked") public I addAliases(final String... aliasArray) { @@ -117,7 +141,9 @@ public abstract class Option { } /** - * @return help for this option. + * Returns the help message for this parameter. + * + * @return the help message as a string. */ public String getHelp() { final StringBuilder result = new StringBuilder(); @@ -142,6 +168,11 @@ public abstract class Option { return result.toString(); } + /** + * Returns the value of the object. + * + * @return the value of the object. + */ public abstract T getValue(); public boolean isMandatory() { @@ -149,14 +180,17 @@ public abstract class Option { } /** - * @return the parameterSpecified + * @return true if this parameter was present in the commandline. */ public boolean isPresent() { return isPresent; } /** - * @param present the parameterSpecified to set + * Sets the present status of this parameter. + * + * @param present true if this parameter is present in the command line, + * false otherwise. */ protected void setPresent(final boolean present) { this.isPresent = present; @@ -192,6 +226,12 @@ public abstract class Option { return true; } + /** + * Sets the option as mandatory. This means that the option must be provided by the user + * in order for the program to run successfully. + * + * @return The updated instance of the option. + */ @SuppressWarnings("unchecked") public I setMandatory() { mandatory = true;