Exemple #1
0
 @Override
 public List<Long> getNanosecondsList(String path) {
   List<Long> l = new ArrayList<Long>();
   List<? extends ConfigValue> list = getList(path);
   for (ConfigValue v : list) {
     if (v.valueType() == ConfigValueType.NUMBER) {
       l.add(TimeUnit.MILLISECONDS.toNanos(((Number) v.unwrapped()).longValue()));
     } else if (v.valueType() == ConfigValueType.STRING) {
       String s = (String) v.unwrapped();
       Long n = parseDuration(s, v.origin(), path);
       l.add(n);
     } else {
       throw new ConfigException.WrongType(
           v.origin(), path, "duration string or number of nanoseconds", v.valueType().name());
     }
   }
   return l;
 }
Exemple #2
0
 @Override
 public List<Long> getBytesList(String path) {
   List<Long> l = new ArrayList<Long>();
   List<? extends ConfigValue> list = getList(path);
   for (ConfigValue v : list) {
     if (v.valueType() == ConfigValueType.NUMBER) {
       l.add(((Number) v.unwrapped()).longValue());
     } else if (v.valueType() == ConfigValueType.STRING) {
       String s = (String) v.unwrapped();
       Long n = parseBytes(s, v.origin(), path);
       l.add(n);
     } else {
       throw new ConfigException.WrongType(
           v.origin(), path, "memory size string or number of bytes", v.valueType().name());
     }
   }
   return l;
 }
Exemple #3
0
 @Override
 public Long getBytes(String path) {
   Long size = null;
   try {
     size = getLong(path);
   } catch (ConfigException.WrongType e) {
     ConfigValue v = find(path, ConfigValueType.STRING);
     size = parseBytes((String) v.unwrapped(), v.origin(), path);
   }
   return size;
 }
Exemple #4
0
 @Override
 public Long getNanoseconds(String path) {
   Long ns = null;
   try {
     ns = TimeUnit.MILLISECONDS.toNanos(getLong(path));
   } catch (ConfigException.WrongType e) {
     ConfigValue v = find(path, ConfigValueType.STRING);
     ns = parseDuration((String) v.unwrapped(), v.origin(), path);
   }
   return ns;
 }
 public InvalidConfigException(
     final ConfigValue value, final String message, final Throwable cause) {
   super(value.origin().description() + ": " + checkNotNull(message), cause);
 }