Quantcast
Channel: Active questions tagged consumer - Stack Overflow
Viewing all articles
Browse latest Browse all 87

Correct use of Java 8 supplier consumer

$
0
0

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 all articles
Browse latest Browse all 87

Trending Articles