title: using java 8 to group list of object by object attribute of type list: JAVA
body: <p>I have an Object like</p>
  
  <pre><code>public class User {
  
      private String id;
      private List&lt;String&gt; brands_ids;
  }
  </code></pre>
  
  <p>and I have a list of User objects like:
  example data</p>
  
  <pre><code>[
    {
      "id": 1,
      "brands_ids": [
        10,
        20,
        30
      ]
    },
    {
      "id": 2,
      "brands_ids": [
        10,
        50
      ]
    },
    {
      "id": 3,
      "brands_ids": [
        10,
        80
      ]
    }
  ]
  </code></pre>
  
  <p>My Question is, How to Group this list to know in which objects the brand id appears, for example brand id=10 appears in all three objects, the brand id=30 only in one object</p>
  
  <p>a result of a map with key=brand id and value = count would solve my issue
  something like this:  {10:3},{20:1},{30,1},{50,1},{80,1}</p>