Removing objects from a list that don't appear in a list of ID's
You can do this without external iteration, if you are using java-8:

items.removeIf(item -&gt; !mediaIds.contains(item.getMediaId()));


It's not necessary to create a new list, this will modify the existing one.