2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2020, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.commons.commandline.parameterparser.parameter;
12 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
13 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
16 import java.util.List;
17 import java.util.stream.Collectors;
19 import static eu.svjatoslav.commons.commandline.parameterparser.parameter.FileParameter.validateFile;
21 public class FileParameters extends Parameter<List<File>, FileParameters> {
23 private ExistenceType existenceType = ExistenceType.DOES_NOT_MATTER;
25 public FileParameters(final String description) {
26 super(description, ArgumentCount.MULTI);
30 public String describeFormat() {
31 return existenceType.description + " files";
35 public List<File> getValue() {
36 return arguments.stream().map(File::new).collect(Collectors.toList());
39 public FileParameters mustExist() {
40 existenceType = ExistenceType.MUST_EXIST;
44 public FileParameters mustNotExist() {
45 existenceType = ExistenceType.MUST_NOT_EXIST;
50 public boolean validate(final String value) {
51 return validateFile(existenceType, value);