Search in sources :

Example 26 with ConfigValue

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;
}
Also used : ConfigValue(com.typesafe.config.ConfigValue)

Example 27 with ConfigValue

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;
}
Also used : ConfigValue(com.typesafe.config.ConfigValue) BigInteger(java.math.BigInteger) ConfigException(com.typesafe.config.ConfigException)

Example 28 with ConfigValue

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);
}
Also used : ConfigValue(com.typesafe.config.ConfigValue) BigInteger(java.math.BigInteger)

Example 29 with ConfigValue

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;
}
Also used : ConfigValue(com.typesafe.config.ConfigValue) ConfigException(com.typesafe.config.ConfigException)

Example 30 with ConfigValue

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));
        }
    }
}
Also used : ConfigValue(com.typesafe.config.ConfigValue) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap)

Aggregations

ConfigValue (com.typesafe.config.ConfigValue)37 Map (java.util.Map)20 Config (com.typesafe.config.Config)11 ConfigException (com.typesafe.config.ConfigException)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 ConfigList (com.typesafe.config.ConfigList)5 ConfigObject (com.typesafe.config.ConfigObject)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Configuration (org.apache.hadoop.conf.Configuration)4 IOException (java.io.IOException)3 BigInteger (java.math.BigInteger)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Properties (java.util.Properties)2 ParaObject (com.erudika.para.core.ParaObject)1 Sysprop (com.erudika.para.core.Sysprop)1 Pager (com.erudika.para.core.utils.Pager)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Gson (com.google.gson.Gson)1 ConfigOrigin (com.typesafe.config.ConfigOrigin)1