I have an Object like
public class User {
private String id;
private List<String> brands_ids;
}
and I have a list of User objects like: example data
[
{
"id": 1,
"brands_ids": [
10,
20,
30
]
},
{
"id": 2,
"brands_ids": [
10,
50
]
},
{
"id": 3,
"brands_ids": [
10,
80
]
}
]
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
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}