public static Map<String, String> filterByKey(
      final Map<String, String> props,
      final Predicate<String> predicate
  ) {
    final Builder<String, String> builder = ImmutableMap.builder();

    props.entrySet().stream()
        .filter(e -> predicate.test(e.getKey()))
        .forEach(e -> builder.put(e.getKey(), e.getValue()));

    return builder.build();
  }
@Test
  public void shouldFilterByKey() {
    // Given:
    final Map<String, String> props = ImmutableMap.of(
        "keep.this", "v0",
        "keep that", "v1",
        "do not keep this", "keep"
    );

    // When:
    final Map<String, String> result = PropertiesUtil
        .filterByKey(props, key -> key.startsWith("keep"));

    // Then:
    assertThat(result.keySet(), containsInAnyOrder("keep.this", "keep that"));
    assertThat(result.get("keep.this"), is("v0"));
    assertThat(result.get("keep that"), is("v1"));
  }