If I understand your filtering criteria correctly, you want to check if the filtered Stream you produced from the value List has any elements, and if so, pass the corresponding Map entry to the output Map.

Map<String, List<BoMLine>>
    filtered = materials.entrySet()
                        .stream()
                        .filter(a->a.getValue()
                                    .stream()
                                    .anyMatch(l->MaterialDao.findMaterialByName(l.getMaterial())))
                        .collect(Collectors.toMap(e->e.getKey(),e->e.getValue()));

This is assuming MaterialDao.findMaterialByName(l.getMaterial()) returns a boolean.

Answer from Eran on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java collections › java map › working with maps using streams
Working With Maps Using Streams | Baeldung
November 10, 2025 - We are interested in finding the ISBN for the book titled “Effective Java.” · Since the book title could not exist in our Map, we want to be able to indicate that there is no associated ISBN for it. We can use an Optional to express that: Let’s assume for this example that we are interested in any key for a book matching that title: Optional<String> optionalIsbn = books.entrySet().stream() .filter(e -> "Effective Java".equals(e.getValue())) .map(Map.Entry::getKey) .findFirst(); assertEquals("978-0134685991", optionalIsbn.get());
Discussions

Golang library for java 8 like streams
Any such library would need to be type-unsafe, use reflection or code generation to work. It's also not considered very Go-like: see https://github.com/robpike/filter for an implementation of apply / reduce and note the author says that it shouldn't be used because for loops are preferred in Go. More on reddit.com
🌐 r/golang
6
3
February 11, 2018
Proposal for stream: a (casting) filter by class
It can be "simplified" with .filter(Circle.class::isInstance) and .map(Circle.class::cast) ;) More on reddit.com
🌐 r/java
8
5
October 12, 2016
Java 8 functional alternative to for loop break
The filter() method (from the Stream interface) along with the findFirst() method would solve your need. More on reddit.com
🌐 r/javahelp
6
7
March 6, 2015
Java Stream Filter Predicate chain está permitindo itens inválidos

Mostra a implementação desse método filtrarporargumento

More on reddit.com
🌐 r/brdev
8
0
November 28, 2024
🌐
Mkyong
mkyong.com › home › java8 › java 8 map filter examples
Java 8 Map filter examples | mkyong.com
March 13, 2024 - package com.mkyong.examples; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; public class MapFilterExample2 { public static void main(String[] args) { Map<Integer, String> map = new HashMap<>(); map.put(1, "linode"); map.put(2, "heroku"); map.put(3, "aws"); //Map -> Stream -> Filter -> String String result1 = map.values().stream() .filter("linode"::equals) .collect(Collectors.joining()); // linode System.out.println(result1); //Map -> Stream -> Filter -> MAP Map<Integer, String> result2 = map.entrySet().stream() .filter(x -> x.getKey() == 1) .collect(Collect
🌐
Medium
medium.com › javarevisited › how-to-use-streams-map-filter-and-collect-methods-in-java-1e13609a318b
How to use map, filter, and collect methods in Java Stream? Example Tutorial | by javinpaul | Javarevisited | Medium
January 25, 2024 - Once we have the Stream of Integer, we can apply maths to find out even numbers. We passed that condition to the filter method. If we needed to filter on String, like select all string which has length > 2, then we would have called filter before map. Before any Java and Spring Developer interview, I always use to read the below resources
🌐
How to do in Java
howtodoinjava.com › home › java streams › filter a map by keys and values using java stream
Filter a Map by Keys and Values using Java Stream
May 3, 2024 - public static final class Filters { private Filters() { throw new AssertionError("Cannot be instantiated"); } public static <K, V> Map<K, V> byKey(Map<K, V> map, Predicate<K> predicate) { Objects.requireNonNull(map); Objects.requireNonNull(predicate); return map.entrySet() .stream() .filter(item -> predicate.test(item.getKey())) .collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue)); } //... }
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Filter a Map by Keys and Values using Java Stream - Java Code Geeks
June 14, 2024 - Discover how to filter a Map by keys, values, or both using Java 8’s Stream API with the filter() and collect() methods. These straightforward code snippets demonstrate how to create generic functions for filtering any Map based on its keys ...
🌐
JRebel
jrebel.com › blog › using-java-stream-map-and-java-stream-filter
Using Java 8 Stream Map and Java 8 Stream Filter | JRebel
June 25, 2025 - The new java.util.stream package has been added to JDK which allows us to perform filter/map/reduce-like operations with the Java 8 collections stream.
Find elsewhere
🌐
BeginnersBook
beginnersbook.com › 2017 › 10 › java-8-filter-a-map-by-keys-and-values
Java 8 – Filter a Map by keys and values
import java.util.Map; import java.util.HashMap; import java.util.stream.Collectors; public class Example { public static void main(String[] args) { Map<Integer, String> hmap = new HashMap<Integer, String>(); hmap.put(11, "Apple"); hmap.put(22, "Orange"); hmap.put(33, "Kiwi"); hmap.put(44, "Banana"); Map<Integer, String> result = hmap.entrySet() .stream() .filter(map -> map.getKey().intValue() <= 22) .collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue())); System.out.println("Result: " + result); } }
🌐
amitph
amitph.com › home › java › using filter on stream of maps in java
Using Filter on Stream of Maps in Java - amitph
November 22, 2024 - This was an example oriented tutorial on Filtering Java Map elements. We have used Java Streams to specify a predicate to filter Map elements and collect the filtered elements in a new HashMap or collect the filtered values into a List.
🌐
SitePoint
sitepoint.com › blog › java › java 8 streams: an intro to filter, map and reduce operations
Java 8 Streams: An Intro to Filter, Map and Reduce Operations — SitePoint
November 7, 2024 - Java 8 includes support for lambda expressions and a powerful Streams API which allows you to work with sequences of elements, such as lists and arrays, in a new way. This includes transforming streams using higher-order methods named map, filter and reduce.
🌐
WPI Computer Science
web.cs.wpi.edu › ~cs2102 › b15 › Labs › map-and-filter.html
Map, Filter, Lambdas and Java Streams
Java doesn’t provide filter and map directly on lists. Instead, these operations work on Streams, a special kind of data for collections of elements, designed to support maps and filters.
🌐
Djamware
djamware.com › post › java-streams-tutorial-filter-map-and-collect-explained
Java Streams Tutorial: Filter, Map, and Collect Explained – Djamware
September 11, 2025 - In this tutorial, we explored how Java Streams simplify data processing by replacing verbose loops with clean, declarative code. We focused on three of the most commonly used methods: filter() – to select elements that match specific conditions. ...
🌐
DZone
dzone.com › coding › languages › java 8 map, filter, and collect examples
Java 8 Map, Filter, and Collect Examples - DZone
June 21, 2018 - Similar to map, the filter is also an intermediate operation, which means you can call other Stream methods after calling the filter. The filter() method is also lazy, meaning it will not be evaluated until you call a reduction method, like collect, and it will stop as soon as it reaches the target. If you are not familiar with Stream behavior, I suggest you check out The Ultimate Java 9 Tutorial, which further explains Stream fundamentals in great detail.
🌐
How to do in Java
howtodoinjava.com › home › java streams › how to filter a map by list of keys in java
How to Filter a Map by List of Keys in Java
September 16, 2022 - In this Java tutorial, we learned to filter a HashMap by keys or values and collect the matching Entry instances into a submap. We also learned to collect the values in a List after filtering the Map keys against a List using Stream.filter() and forEach() APIs.
🌐
Medium
medium.com › spring-boot › java-stream-operations-filter-map-reduce-and-collect-65a1287ac2e0
Java Stream Operations: Filter, Map, Reduce, and Collect | by Piyu Jain | JavaToDev | Medium
May 23, 2023 - For example, you can filter a stream to select specific elements, map them to a different data type, perform calculations on the mapped elements using the reduce operation, and finally collect the results into a collection or a single value using the collect operation. In conclusion, Java streams provide a powerful and expressive way to process collections of data.
🌐
Stack Abuse
stackabuse.com › how-to-filter-a-map-by-key-or-value-in-java
How to Filter a Map by Key or Value in Java
October 7, 2023 - In this tutorial, we'll take a look at how to filter a Map by key or value in Java 8, using an enhanced for-loop and the Stream API's `filter()` method, with examples.
🌐
MIT
web.mit.edu › 6.031 › www › fa17 › classes › 26-map-filter-reduce
Reading 26: Map, Filter, Reduce
Given a Stream<File> files, we can now write, e.g., files.filter(endsWith(".java")) to obtain a new filtered stream. endsWith is a different kind of beast than our usual functions. It’s a higher-order function, meaning that it’s a function that takes another function as an argument, or returns another function as its result. Higher-order functions are operations on the datatype of functions; in this case, endsWith is a creator of functions. Now let’s use map and filter to recursively traverse the folder tree:
🌐
Attacomsian
attacomsian.com › blog › java-filter-map
How to filter a Map with Java 8 Stream API
October 8, 2022 - Let us have another example to ... object: Map<String, Integer> output = employees.entrySet() .stream() .filter(e -> e.getValue() > 3000 && e.getValue() < 5000) .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); // print output ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › stream › Stream.html
Stream (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... A sequence of elements supporting sequential and parallel aggregate operations. The following example illustrates an aggregate operation using Stream and IntStream: int sum = widgets.stream() .filter(w -> w.getColor() == RED) .mapToInt(w -> w.getWeight()) .sum(); In this example, widgets is a Collection<Widget>. We create a stream of Widget objects via Collection.stream(), filter it to produce a stream containing only the red widgets, and then transform it into a stream of int values representing the weight of each red widget.
🌐
Blogger
javarevisited.blogspot.com › 2018 › 05 › java-8-filter-map-collect-stream-example.html
How to use filter + map + collect + Stream in Java? Example Tutorial
May 22, 2018 - Once we got the Stream of Integer, we can apply maths to find out even numbers, and we passed that condition to the filter method. If we needed to filter on String, like select all string which has length > 2 then we would have called filter before map. That's all about how to use map and filter in Java 8.