The Java Stream API: Collecting Into Maps
You can view the sample code associated with this post on GitHub.
Taking a stream of POJOs and transforming it into a map is one of the more common uses of Streams.
There are a few built in ways to get what you want. The simplest way to map one field to another in a POJO is by
using the .toMap(..)
method.