### Question:
ImmutableMapFactory { public static <K, V> ImmutableMap<K, V> parseAndFilter( String s, Function<String, K> keyParser, Function<String, V> valueParser, BiPredicate<K, V> filter) { Builder<K, V> mapBuilder = ImmutableMap.builder(); for (String objectAndWeight : s.split(";")) { String[] keyAndWeight = objectAndWeight.split(":"); K key = keyParser.apply(keyAndWeight[0]); V value = valueParser.apply(keyAndWeight[1]); if (filter.test(key, value)) { mapBuilder.put(key, value); } } return mapBuilder.build(); }  static ImmutableMap<L, W> create(
            Map<K, V> baseMap,
            BiFunction<? super K, ? super V, ? extends L> keyCreator,
            BiFunction<? super K, ? super V, ? extends W> valueCreator); static ImmutableMap<L, W> create(
            Map<K, V> baseMap,
            Function<? super K, ? extends L> keyMapper,
            Function<? super V, ? extends W> valueMapper); static ImmutableMap<L, W> createAndReduceCollisions(
            Map<K, V> baseMap,
            Function<? super K, ? extends L> keyMapper,
            Function<? super V, ? extends W> valueMapper,
            W valueIdentity,
            BinaryOperator<W> collidingKeysAccumulator); static ImmutableMap<L, V> createWithNewKeys(
            Map<K, V> baseMap,
            Function<? super K, ? extends L> keyMapper); static ImmutableMap<K, W> createWithNewValues(
            Map<K, V> baseMap,
            Function<? super V, ? extends W> valueMapper); static ImmutableMap<K, W> createWithNewValues(
            Map<K, V> baseMap,
            BiFunction<? super K, ? super V, ? extends W> valueMapper); static ImmutableMap<K, V> createFromKeys(
            Collection<K> keys,
            Supplier<V> valueSupplier); static ImmutableMap<K, V> createFromKeys(
            Collection<K> keys,
            Function<K, V> valueCreator); static ImmutableMap<K, V> zip(
            List<K> keys,
            List<V> values); static ImmutableMap<K, V> filter(
            Map<K, V> baseMap,
            BiPredicate<K, V> filter); static ImmutableMap<K, V> filterByKeys(
            Map<K, V> baseMap,
            Predicate<K> keyFilter); static ImmutableMap<K, V> filterByValues(
            Map<K, V> baseMap,
            Predicate<V> valueFilter); static ImmutableMap<K, V> parse(
            String s,
            Function<String, K> keyParser,
            Function<String, V> valueParser); static ImmutableMap<K, V> parseAndFilter(
            String s,
            Function<String, K> keyParser,
            Function<String, V> valueParser,
            BiPredicate<K, V> filter);  }### Answer:
@Test void testParseAndFilter() { String toParse = "A:1;B:2;C:3;D:4"; ImmutableMap<String, Integer> parsed = ImmutableMapFactory.parseAndFilter( toParse, s -> s, Integer::parseInt, (key, value) -> !key.equals("A") && value < 4); Assertions.assertEquals(ImmutableMap.of("B", 2, "C", 3), parsed); }
@Test void testParseAndFilterNoneRemain() { String toParse = "A:1;B:2;C:3;D:4"; ImmutableMap<String, Integer> parsed = ImmutableMapFactory.parseAndFilter( toParse, s -> s, Integer::parseInt, (key, value) -> !key.equals("A") && value > 4); ImmutableMap<String, Integer> expected = ImmutableMap.of(); Assertions.assertEquals(expected, parsed); }