Add Javadoc comments to enhance code clarity
[cli-helper.git] / src / main / java / eu / svjatoslav / commons / cli_helper / parameter_parser / parameter / FileOption.java
index db941c4..c10ec1e 100755 (executable)
@@ -9,12 +9,16 @@ import eu.svjatoslav.commons.cli_helper.parameter_parser.Option;
 
 import java.io.File;
 
+/**
+ * This class represents commandline option which accepts exactly one parameter
+ * which is a file.
+ */
 public class FileOption extends Option<File, FileOption> {
 
     private ExistenceType existenceType = ExistenceType.DOES_NOT_MATTER;
 
     public FileOption(final String description) {
-        super(description, ParameterCount.SINGLE);
+        super(description, ParameterCount.ONE);
     }
 
     protected static boolean validateFile(ExistenceType existenceType, String value) {
@@ -41,7 +45,14 @@ public class FileOption extends Option<File, FileOption> {
 
     @Override
     public java.lang.String describeFormat() {
-        return existenceType.description + " file";
+        switch (existenceType) {
+            case MUST_EXIST:
+                return "Existing file.";
+            case MUST_NOT_EXIST:
+                return "Non-existing file.";
+            default:
+                return "File.";
+        }
     }
 
     @Override
@@ -54,11 +65,21 @@ public class FileOption extends Option<File, FileOption> {
         return new File(parameters.get(0));
     }
 
+    /**
+     * This method sets that file shall exist.
+     *
+     * @return This object.
+     */
     public FileOption mustExist() {
         existenceType = ExistenceType.MUST_EXIST;
         return this;
     }
 
+    /**
+     * This method sets that file shall not exist.
+     *
+     * @return This object.
+     */
     public FileOption mustNotExist() {
         existenceType = ExistenceType.MUST_NOT_EXIST;
         return this;