Add Javadoc comments to enhance code clarity
[cli-helper.git] / src / main / java / eu / svjatoslav / commons / cli_helper / parameter_parser / parameter / DirectoryOption.java
index 718aa09..ee52751 100755 (executable)
@@ -9,10 +9,22 @@ import eu.svjatoslav.commons.cli_helper.parameter_parser.Option;
 
 import java.io.File;
 
+
+/**
+ * This class is used to define commandline option which accepts directory as parameter.
+ */
 public class DirectoryOption extends Option<File, DirectoryOption> {
 
+    /**
+     * This enum is used to define if directory shall exist in filesystem or not.
+     */
     private ExistenceType existenceType = ExistenceType.DOES_NOT_MATTER;
 
+    /**
+     * Constructor.
+     *
+     * @param description Description of the option.
+     */
     public DirectoryOption(final String description) {
         super(description, ParameterCount.ONE);
     }
@@ -29,6 +41,12 @@ public class DirectoryOption extends Option<File, DirectoryOption> {
         }
     }
 
+    /**
+     * Retrieves the value of the option as a {@link File} object.
+     *
+     * @return The value of the option as a {@link File} object.
+     * @throws RuntimeException if the option does not have exactly 1 argument.
+     */
     @Override
     public File getValue() {
 
@@ -39,16 +57,32 @@ public class DirectoryOption extends Option<File, DirectoryOption> {
         return new File(parameters.get(0));
     }
 
+    /**
+     * This method sets that directory shall exist.
+     *
+     * @return This object.
+     */
     public DirectoryOption mustExist() {
         existenceType = ExistenceType.MUST_EXIST;
         return this;
     }
 
+    /**
+     * This method sets that directory shall not exist.
+     *
+     * @return This object.
+     */
     public DirectoryOption mustNotExist() {
         existenceType = ExistenceType.MUST_NOT_EXIST;
         return this;
     }
 
+    /**
+     * This method checks if a provided directory path is valid based on the specified existence type.
+     *
+     * @param value The directory path to validate.
+     * @return True if the directory path is valid according to the existence type, otherwise false.
+     */
     @Override
     public boolean isValid(final java.lang.String value) {
         final File file = new File(value);