There are two sets of objects, for example users - one from db(userSetDb) and another one - newly created objects (userSet). I need to compare these 2 sets, if userSetDb contains an element from userSet, set the fields (for example phone number) of users from userSetDb to phone numbers from userSet. (phone number field is not included into overridden equals method )
I cannot finish Stream API expression:
userSetDb.stream().filter(u -> userSet.contains(u))
.map(u -> userSet.stream().filter(u1 -> u1.equals(u))....
I know that I can remove similar users from userSetDb at first and then add all from userSet. But I wonder how I can do it using stream inside another stream. Is it a good practice to use stream in stream?