private void updateUserDevices(final String username, Collection<Device> devices, Collection<String> contacts) { // put all the device contact info in the list and then filter out the ones in the given devices collection. devices.stream() .filter(d -> !contacts.contains(d.getContact())) .forEach(MyService::delete); } private void delete(Device d) { String contact = d.getContact(); if (d.isEmail()) { deleteEmail(contact); } else { deleteSms(contact); } } private void deleteEmail(String email) {} private void deleteSms(String sms) {}