Add Javadoc comments to enhance code clarity
[cli-helper.git] / src / main / java / eu / svjatoslav / commons / cli_helper / parameter_parser / Option.java
index 9bcea3f..d591663 100755 (executable)
@@ -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 <T> type of value that this option returns.
+ * @param <I> type of this option.
+ */
 public abstract class Option<T, I extends Option> {
 
     /**
@@ -43,6 +51,16 @@ public abstract class Option<T, I extends 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<T, I extends 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<T, I extends 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<T, I extends 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<T, I extends Option> {
     }
 
     /**
-     * @return the parameterSpecified
+     * @return <code>true</code> 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 <code>true</code> if this parameter is present in the command line,
+     *                <code>false</code> otherwise.
      */
     protected void setPresent(final boolean present) {
         this.isPresent = present;
@@ -192,6 +226,12 @@ public abstract class Option<T, I extends 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;