Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Collection;

import java.util.Map;

import java.util.function.Predicate;
import java.util.stream.Collectors;

public class Main {
    public static <Key, Value> Collection<Value> filterMapValuesByKey(Map<Key, Value> map,
            Predicate<Key> keyPredicate) {
        return map.entrySet().parallelStream().filter(entry -> keyPredicate.test(entry.getKey()))
                .map(Map.Entry::getValue).collect(Collectors.toList());
    }
}