*/
package eu.svjatoslav.commons.cli_helper.parameter_parser.parameter;
-import eu.svjatoslav.commons.cli_helper.parameter_parser.ParameterCount;
import eu.svjatoslav.commons.cli_helper.parameter_parser.Option;
+import eu.svjatoslav.commons.cli_helper.parameter_parser.ParameterCount;
import java.io.File;
import java.util.List;
import static eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption.validateFile;
+/**
+ * This class represents commandline option which accepts one or more parameters
+ * which are files.
+ */
public class FileOptions extends Option<List<File>, FileOptions> {
private ExistenceType existenceType = ExistenceType.DOES_NOT_MATTER;
public FileOptions(final String description) {
- super(description, ParameterCount.MULTI);
+ super(description, ParameterCount.ONE_OR_MORE);
}
@Override
public String describeFormat() {
- return existenceType.description + " files";
+ switch (existenceType) {
+ case MUST_EXIST:
+ return "One to many existing files.";
+ case MUST_NOT_EXIST:
+ return "One to many non-existing files.";
+ default:
+ return "One to many files.";
+ }
}
@Override
return parameters.stream().map(File::new).collect(Collectors.toList());
}
+ /**
+ * This method is used to define that file shall exist in filesystem.
+ *
+ * @return This object.
+ */
public FileOptions mustExist() {
existenceType = ExistenceType.MUST_EXIST;
return this;
}
+ /**
+ * This method is used to define that file shall not exist in filesystem.
+ *
+ * @return This object.
+ */
public FileOptions mustNotExist() {
existenceType = ExistenceType.MUST_NOT_EXIST;
return this;