use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method getDuration.
@Override
public long getDuration(String path, TimeUnit unit) {
ConfigValue v = find(path, ConfigValueType.STRING);
long result = unit.convert(parseDuration((String) v.unwrapped(), v.origin(), path), TimeUnit.NANOSECONDS);
return result;
}
use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method getBytesBigInteger.
private BigInteger getBytesBigInteger(String path) {
BigInteger bytes;
ConfigValue v = find(path, ConfigValueType.STRING);
try {
bytes = BigInteger.valueOf(getLong(path));
} catch (ConfigException.WrongType e) {
bytes = parseBytes((String) v.unwrapped(), v.origin(), path);
}
if (bytes.signum() < 0)
throw new ConfigException.BadValue(v.origin(), path, "Attempt to construct memory size with negative number: " + bytes);
return bytes;
}
use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method getBytes.
@Override
public Long getBytes(String path) {
BigInteger bytes = getBytesBigInteger(path);
ConfigValue v = find(path, ConfigValueType.STRING);
return toLong(bytes, v.origin(), path);
}
use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method hasPathPeek.
private ConfigValue hasPathPeek(String pathExpression) {
Path path = Path.newPath(pathExpression);
ConfigValue peeked;
try {
peeked = object.peekPath(path);
} catch (ConfigException.NotResolved e) {
throw ConfigImpl.improveNotResolved(path, e);
}
return peeked;
}
use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method findPaths.
private static void findPaths(Set<Map.Entry<String, ConfigValue>> entries, Path parent, AbstractConfigObject obj) {
for (Map.Entry<String, ConfigValue> entry : obj.entrySet()) {
String elem = entry.getKey();
ConfigValue v = entry.getValue();
Path path = Path.newKey(elem);
if (parent != null)
path = path.prepend(parent);
if (v instanceof AbstractConfigObject) {
findPaths(entries, path, (AbstractConfigObject) v);
} else if (v instanceof ConfigNull) {
// nothing; nulls are conceptually not in a Config
} else {
entries.add(new AbstractMap.SimpleImmutableEntry<String, ConfigValue>(path.render(), v));
}
}
}
Aggregations