ConfigUtil { public static <T> Optional<T> get(Config config, Function<String, T> getter, String path) { if (!config.hasPath(path)) { return Optional.empty(); } return Optional.of(getter.apply(path)); } private  ConfigUtil(); static Optional<T> get(Config config, Function<String, T> getter, String path);  }
@Test public void getShouldReturnValue() { final Config config = ConfigFactory.parseMap(Map.of("foo.bar", "baz")); assertThat(ConfigUtil.get(config, config::getString, "foo.bar"), is(Optional.of("baz"))); }
@Test public void getShouldReturnEmpty() { final Config config = ConfigFactory.empty(); assertThat(ConfigUtil.get(config, config::getString, "foo.bar"), is(Optional.empty())); }