class ImmutableMapFactory {

    public static <K, V> ImmutableMap<K, V> filter(
            Map<K, V> baseMap,
            BiPredicate<K, V> filter) {
        return baseMap.entrySet().stream()
                .filter(e -> filter.test(e.getKey(), e.getValue()))
                .collect(ImmutableMap.toImmutableMap(
                        Entry::getKey,
                        Entry::getValue));
    }

}