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.

Revisions

  1. iintothewind created this gist Jun 24, 2020.
    7 changes: 7 additions & 0 deletions config.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    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);
    }