com.sampullara.cli.Args.createValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.sampullara.cli.Args.createValue()方法的一些代码示例,展示了Args.createValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Args.createValue()方法的具体详情如下:
包路径:com.sampullara.cli.Args
类名称:Args
方法名:createValue

Args.createValue介绍

暂无

代码示例

代码示例来源:origin: com.github.spullara.cli-parser/cli-parser

private static Object getValue(Class<?> type, Object value, String delimiter) throws NoSuchMethodException {
  if (type != String.class && type != Boolean.class && type != Boolean.TYPE) {
    String string = (String) value;
    if (type.isArray()) {
      String[] strings = string.split(delimiter);
      type = type.getComponentType();
      if (type == String.class) {
        value = strings;
      } else {
        Object[] array = (Object[]) Array.newInstance(type, strings.length);
        for (int i = 0; i < array.length; i++) {
          array[i] = createValue(type, strings[i]);
        }
        value = array;
      }
    } else {
      value = createValue(type, string);
    }
  }
  return value;
}

代码示例来源:origin: com.google.code.cli-parser/cli

private static Object getValue(Class type, Object value, String delimiter) throws NoSuchMethodException {
  if (type != String.class && type != Boolean.class && type != Boolean.TYPE) {
    if (type.isArray()) {
      String string = (String) value;
      String[] strings = string.split(delimiter);
      type = type.getComponentType();
      if (type == String.class) {
        value = strings;
      } else {
        Object[] array = (Object[]) Array.newInstance(type, strings.length);
        for (int i = 0; i < array.length; i++) {
          array[i] = createValue(type, strings[i]);
        }
        value = array;
      }
    } else {
      value = createValue(type, value);
    }
  }
  return value;
}

代码示例来源:origin: spullara/cli-parser

private static Object getValue(Class<?> type, Object value, String delimiter) throws NoSuchMethodException {
  if (type != String.class && type != Boolean.class && type != Boolean.TYPE) {
    String string = (String) value;
    if (type.isArray()) {
      String[] strings = string.split(delimiter);
      type = type.getComponentType();
      if (type == String.class) {
        value = strings;
      } else {
        Object[] array = (Object[]) Array.newInstance(type, strings.length);
        for (int i = 0; i < array.length; i++) {
          array[i] = createValue(type, strings[i]);
        }
        value = array;
      }
    } else {
      value = createValue(type, string);
    }
  }
  return value;
}

相关文章