title: Counting items from Map having Set as value
body: <p>I have a list of items as below</p>
  
  <pre><code>List&lt;SomeModel&gt; smList = new ArrayList&lt;&gt;();
  
      smList.add(new SomeModel(1L,6.0f));//id = 1L and capacity = 6.0f
      smList.add(new SomeModel(2L,7.0f));
      smList.add(new SomeModel(3L,7.0f));
      smList.add(new SomeModel(4L,7.0f));
  </code></pre>
  
  <p>Now I am converting this list into </p>
  
  <pre><code>Map&lt;Float, Set&lt;Long&gt;&gt; complexList = new HashMap&lt;&gt;();
          complexList = smList.stream().collect(Collectors.groupingBy(SomeModel::getCapacity,
                  Collectors.mapping(SomeModel::getId, Collectors.toSet())));
  </code></pre>
  
  <p>here complexList
  gives output as </p>
  
  <pre><code>7.0=[2, 3, 4]
  6.0=[1]
  </code></pre>
  
  <p>Now I need to count number of values for each "capacity" giving output as </p>
  
  <pre><code>7.0=3
  6.0=1
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>Map&lt;Float, Long&gt; complexCount = complexList.entrySet().stream().
                  collect(Collectors.groupingBy(Map.Entry::getKey, 
                          Collectors.mapping(Map.Entry::getValue, Collectors.counting())));
          complexCount.forEach((k,v)-&gt;System.out.println(k+"="+v));
  </code></pre>
  
  <p>and it outputs </p>
  
  <pre><code>6.0=1
  7.0=1
  </code></pre>
  
  <p>I must be mistaking in understanding streams or not be using right methods. Can anyone suggest an approach or a solution? Reference link to streams will also be  helpful.</p>