I am comparing two lists.
List allUserGroups = UserBC.getAllGroupsForUser(userId, deptID);
List<String> confUserGroups= Arrays.asList(configuredSet);
List one returns Object which I need to typecast to GroupData entity. GroupData has multiple fields and want to compare for one of the fields 'id'. So I used map function to typecast as below,
isValuePresent = allUserGroups.stream().map(p -> (GroupData) p).anyMatch(p -> confUserGroups.contains(p.getId()));
Issue is, for p.getId()
its again asking for typecast. Compiler asks to add cast again. Can anyone please suggest if I missed anything.
EDIT1:
id is of long type otherwise I could have used ((GroupData)p).getId()
EDIT2: Modified the code as answered by Joop, but getting same error