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));
}
}
}
use of com.typesafe.config.ConfigValue in project config by typesafehub.
the class SimpleConfig method getBytesList.
@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;
}
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 scoold by Erudika.
the class AdminController method get.
@GetMapping
public String get(HttpServletRequest req, Model model) {
if (!utils.isAuthenticated(req) || !utils.isAdmin(utils.getAuthUser(req))) {
return "redirect:" + HOMEPAGE;
}
Map<String, Object> configMap = new HashMap<String, Object>();
for (Map.Entry<String, ConfigValue> entry : Config.getConfig().entrySet()) {
ConfigValue value = entry.getValue();
configMap.put(Config.PARA + "_" + entry.getKey(), value != null ? value.unwrapped() : "-");
}
configMap.putAll(System.getenv());
model.addAttribute("path", "admin.vm");
model.addAttribute("title", utils.getLang(req).get("admin.title"));
model.addAttribute("configMap", configMap);
model.addAttribute("version", pc.getServerVersion());
return "base";
}
Aggregations