This is extension to my this question
I want to fetch id from a List below,
List allUserGroups = UserBC.getAllGroupsForUser(userId, deptID);
This List has Objects which I need to typecast to GroupData entity. GroupData extends PartyData which has getId() method defined in it. So I tried using labda as ,
allUserGroups.stream()
.map(GroupData.class::cast)
.map(GroupData::getId)
Issue here is, compiler shows The type GroupData does not define getId(Object) that is applicable here.
The type GroupData does not define getId(Object) that is applicable here
It works fine with normal for loop,
for(Object userGroup: allUserGroups){
long usergrp = ((GroupData) userGroup ).getId();
}
Can anyone suggest how to achieve this using Labmda