com.typesafe.config.Config.getDurationList()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(147)

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

Config.getDurationList介绍

[英]Gets a list, converting each value in the list to a duration, using the same rules as #getDuration(String,TimeUnit).
[中]获取一个列表,使用与#getDuration(字符串,时间单位)相同的规则将列表中的每个值转换为持续时间。

代码示例

代码示例来源:origin: kairosdb/kairosdb

@Override
  public List<?> extractListValue(Config config, String path) {
    return config.getDurationList(path);
  }
},

代码示例来源:origin: atomix/atomix

return config.getStringList(configPropName);
} else if (elementType == Duration.class) {
 return config.getDurationList(configPropName);
} else if (elementType == MemorySize.class) {
 List<ConfigMemorySize> sizes = config.getMemorySizeList(configPropName);

代码示例来源:origin: mpusher/mpush

private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
  Type elementType = ((ParameterizedType) parameterType).getActualTypeArguments()[0];
  if (elementType == Boolean.class) {
    return config.getBooleanList(configPropName);
  } else if (elementType == Integer.class) {
    return config.getIntList(configPropName);
  } else if (elementType == Double.class) {
    return config.getDoubleList(configPropName);
  } else if (elementType == Long.class) {
    return config.getLongList(configPropName);
  } else if (elementType == String.class) {
    return config.getStringList(configPropName);
  } else if (elementType == Duration.class) {
    return config.getDurationList(configPropName);
  } else if (elementType == ConfigMemorySize.class) {
    return config.getMemorySizeList(configPropName);
  } else if (elementType == Object.class) {
    return config.getAnyRefList(configPropName);
  } else if (elementType == Config.class) {
    return config.getConfigList(configPropName);
  } else if (elementType == ConfigObject.class) {
    return config.getObjectList(configPropName);
  } else if (elementType == ConfigValue.class) {
    return config.getList(configPropName);
  } else {
    throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported list element type " + elementType);
  }
}

代码示例来源:origin: dremio/dremio-oss

@Override
public List<Long> getDurationList(String arg0, TimeUnit arg1) {
 return config.getDurationList(arg0, arg1);
}

代码示例来源:origin: racc/typesafeconfig-guice

@Override
  public List<?> extractListValue(Config config, String path) {
    return config.getDurationList(path);
  }
},

代码示例来源:origin: com.github.ddth/ddth-commons-core

/**
 * Get a configuration as list of durations (parses special strings like "10s"). Return
 * {@code null} if missing, wrong type or bad value.
 *
 * @param config
 * @param path
 * @return
 */
public static List<Duration> getDurationList(Config config, String path) {
  try {
    return config.getDurationList(path);
  } catch (ConfigException.Missing | ConfigException.WrongType | ConfigException.BadValue e) {
    if (e instanceof ConfigException.WrongType || e instanceof ConfigException.BadValue) {
      LOGGER.warn(e.getMessage(), e);
    }
    return null;
  }
}

代码示例来源:origin: com.github.ddth/ddth-commons-core

/**
 * Get a configuration as list of durations (parses special strings like "10s"). Return
 * {@code null} if missing, wrong type or bad value.
 *
 * @param config
 * @param path
 * @param timeUnit
 * @return
 */
public static List<Long> getDurationList(Config config, String path, TimeUnit timeUnit) {
  try {
    return config.getDurationList(path, timeUnit);
  } catch (ConfigException.Missing | ConfigException.WrongType | ConfigException.BadValue e) {
    if (e instanceof ConfigException.WrongType || e instanceof ConfigException.BadValue) {
      LOGGER.warn(e.getMessage(), e);
    }
    return null;
  }
}

代码示例来源:origin: io.atomix/atomix-utils

return config.getStringList(configPropName);
} else if (elementType == Duration.class) {
 return config.getDurationList(configPropName);
} else if (elementType == MemorySize.class) {
 List<ConfigMemorySize> sizes = config.getMemorySizeList(configPropName);

代码示例来源:origin: com.github.mpusher/mpush-tools

private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
  Type elementType = ((ParameterizedType) parameterType).getActualTypeArguments()[0];
  if (elementType == Boolean.class) {
    return config.getBooleanList(configPropName);
  } else if (elementType == Integer.class) {
    return config.getIntList(configPropName);
  } else if (elementType == Double.class) {
    return config.getDoubleList(configPropName);
  } else if (elementType == Long.class) {
    return config.getLongList(configPropName);
  } else if (elementType == String.class) {
    return config.getStringList(configPropName);
  } else if (elementType == Duration.class) {
    return config.getDurationList(configPropName);
  } else if (elementType == ConfigMemorySize.class) {
    return config.getMemorySizeList(configPropName);
  } else if (elementType == Object.class) {
    return config.getAnyRefList(configPropName);
  } else if (elementType == Config.class) {
    return config.getConfigList(configPropName);
  } else if (elementType == ConfigObject.class) {
    return config.getObjectList(configPropName);
  } else if (elementType == ConfigValue.class) {
    return config.getList(configPropName);
  } else {
    throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported list element type " + elementType);
  }
}

相关文章