use generics for more elegant code
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / commandline / parameterparser / parameter / DirectoryParameter.java
old mode 100644 (file)
new mode 100755 (executable)
index 8607234..1c11a48
@@ -1,24 +1,25 @@
+/*
+ * Svjatoslav Commons - shared library of common functionality.
+ * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
 package eu.svjatoslav.commons.commandline.parameterparser.parameter;
 
 import java.io.File;
 
-import eu.svjatoslav.commons.commandline.parameterparser.Argument;
 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
-import eu.svjatoslav.commons.commandline.parameterparser.type.StringArgument;
 
-public class DirectoryParameter extends Parameter implements Argument {
+public class DirectoryParameter extends Parameter<DirectoryParameter> {
 
        private ExistanceType existanceType = ExistanceType.DOES_NOT_MATTER;
 
        public DirectoryParameter(final String description) {
-               super(new StringArgument(), description, ArgumentCount.SINGLE);
-       }
-
-       @Override
-       public DirectoryParameter addAliases(final String... aliasArray) {
-               super.addAliases(aliasArray);
-               return this;
+               super(description, ArgumentCount.SINGLE);
        }
 
        @Override
@@ -26,6 +27,7 @@ public class DirectoryParameter extends Parameter implements Argument {
                return existanceType.description + "directory";
        }
 
+       @Override
        public File getValue() {
 
                if (arguments.size() != 1)
@@ -45,12 +47,6 @@ public class DirectoryParameter extends Parameter implements Argument {
                return this;
        }
 
-       @Override
-       public DirectoryParameter setMandatory() {
-               mandatory = true;
-               return this;
-       }
-
        @Override
        public boolean validate(final java.lang.String value) {
                final File file = new File(value);