That code looks a bit like trying to produce the implementation before you worked out exactly
what you want to do. It also looks as if your classes didn't have enough methods. It might be unusual to get the month without the rest of the date, but in this case I think
Employee should have a
getStartMonth() method if you are using that month number.
Streams work best with straightforward operations, and a two‑stage procedure might be easier.
Please explain more; we need
details and information.
Is
Statement a two‑element
enum? Does
values() return a
List<Employee>?
Why are you using
BigDecimals for something with values 1, 2? Why is it declared as
Object? Are you going to have to cast that field and have the cast fail?
Why can't you simply use month and groupingBy? That will of course give you a
Map<Integer, List<Employee>>.
If you group by the
id String instead, it should be easy enough to traverse the resulting
Map and convert the
List<Employee> to another object encapsulating the
Lists, with a method to return the
Lists'
size()s.