2 * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.commons.cli_helper.parameter_parser.parameter;
7 import eu.svjatoslav.commons.cli_helper.parameter_parser.ParameterCount;
8 import eu.svjatoslav.commons.cli_helper.parameter_parser.Option;
10 public class StringOption extends Option<String, StringOption> {
12 public final String defaultValue;
14 public StringOption(final String description) {
15 super(description, ParameterCount.ONE);
18 public StringOption(final String description, String defaultValue) {
19 super(description, ParameterCount.ONE);
20 this.defaultValue = defaultValue;
21 this.setPresent(true);
25 public java.lang.String describeFormat() {
30 public String getValue() {
32 if (parameters.isEmpty() && (defaultValue != null)) return defaultValue;
34 if (parameters.size() == 1) return parameters.get(0);
36 throw new RuntimeException("Parameter " + description
37 + " shall have exactly 1 argument.");
41 public boolean isValid(final java.lang.String value) {