Example usage for org.apache.commons.cli TypeHandler createValue

List of usage examples for org.apache.commons.cli TypeHandler createValue

Introduction

In this page you can find the example usage for org.apache.commons.cli TypeHandler createValue.

Prototype

public static Object createValue(String str, Class clazz) throws ParseException 

Source Link

Document

Returns the Object of type clazz with the value of str.

Usage

From source file:de.mustnotbenamed.quickstart.undertowserver.CliHelper.java

public static <T> T option(CommandLine cmd, Option option, T defaultValue) throws ParseException {
    T result = defaultValue;/*from w ww . j a  v a  2  s  .c o  m*/

    if (cmd.hasOption(option.getOpt())) {
        String optionValue = cmd.getOptionValue(option.getOpt());
        result = (T) TypeHandler.createValue(optionValue, option.getType());
    }

    return result;
}