Skip to content

Instantly share code, notes, and snippets.

@iintothewind
Created June 24, 2020 13:27
Show Gist options
  • Save iintothewind/1b82aa8b04f8cc86a155389bd3402068 to your computer and use it in GitHub Desktop.
Save iintothewind/1b82aa8b04f8cc86a155389bd3402068 to your computer and use it in GitHub Desktop.
load config entries as Map
static Seq<Tuple2<String, Integer>> loadWeightEntries(final String path) {
Preconditions.checkArgument(Objects.nonNull(path) && path.endsWith("weight"), "invalid path");
final Config weight = CfgUtil.cfg.getConfig(path);
final Map<String, Integer> map = weight.root().keySet().stream().collect(Collectors.toMap(k -> k, weight::getInt));
return List.ofAll(map.entrySet().stream().map(e -> Tuple.of(e.getKey(), e.getValue()))).sortBy(t -> t._1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment