All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openmuc.j62056.internal.cli.StringCliParameter Maven / Gradle / Ivy

Go to download

j62056, a library for reading meters using IEC 62056-21 in modes A, B, C or D.

There is a newer version: 2.2.0
Show newest version
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("\".");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy