public class StringParameter extends Parameter<String, StringParameter> {
+ public final String defaultValue;
+
public StringParameter(final String description) {
super(description, ArgumentCount.SINGLE);
+ defaultValue = null;
+ }
+ public StringParameter(final String description, String defaultValue) {
+ super(description, ArgumentCount.SINGLE);
+ this.defaultValue = defaultValue;
+ this.setSpecified(true);
}
@Override
@Override
public String getValue() {
- if (arguments.size() != 1)
- throw new RuntimeException("Parameter " + description
- + " shall have exactly 1 argument.");
+ if (arguments.isEmpty() && (defaultValue != null)) return defaultValue;
+
+ if (arguments.size() == 1) return arguments.get(0);
- return arguments.get(0);
+ throw new RuntimeException("Parameter " + description
+ + " shall have exactly 1 argument.");
}
@Override