Quantcast
Viewing latest article 21
Browse Latest Browse All 86

Correct use of Java 8 supplier consumer

I'm still strugling with Suppliers and Consumers for Java 8, I have this:

final Set<String> roles = new HashSet<>();user.getRoleGroups().forEach(rg -> rg.getRoles().forEach(r -> roles.add(r.getName())));

To get a Set from role names that are inside a list of Roles inside a list of RoleGroups.Pretty sure I could use something in one line with .stream().map() and RoleGroup::getRoles and Role::getName to get this Set. But I don't know how.


Viewing latest article 21
Browse Latest Browse All 86

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>