Following the same principles found in filtering a map by keys and filtering a map by entries, this example will show how to filter a map by values while using java, java 8 and guava. The snippets below will use a map defined in the @setup that contains entries of months where the key is the integer month (2=February) of year and the value represents the month spelled out.
Straight up Java
Until java 8, the core jdk lack the mechanics for filtering a map by Map.value. The snippet below shows the only effective way is to iterate over the Map.entrySet using a enhanced for loop and then applying criteria in an if statement, in this case checking if entry.value ends with "r".
This example snippet will show how to filter a map by values using java 8. Using the powerful streams api, we will call entrySet.stream and filter values that end with "r" by creating a java.util.function.predicate using a lambda expression. Then using Collectors.toMap we will map each element in the stream back into a map.