org.openmuc.j62056.internal.cli.StringCliParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of j62056 Show documentation
Show all versions of j62056 Show documentation
j62056, a library for reading meters using IEC 62056-21 in modes A, B, C or D.
package org.openmuc.j62056.internal.cli;
public class StringCliParameter extends ValueCliParameter {
String value;
StringCliParameter(CliParameterBuilder builder, String parameterName, String defaultValue) {
super(builder, parameterName);
value = defaultValue;
}
StringCliParameter(CliParameterBuilder builder, String parameterName) {
super(builder, parameterName);
}
public String getValue() {
return value;
}
@Override
int parse(String[] args, int i) throws CliParseException {
selected = true;
if (args.length < (i + 2)) {
throw new CliParseException("Parameter " + name + " has no value.");
}
value = args[i + 1];
return 2;
}
@Override
public void appendDescription(StringBuilder sb) {
super.appendDescription(sb);
if (value != null) {
sb.append(" Default is \"").append(value).append("\".");
}
}
}