Pass method as parameter and using in a forEach loop
<p>I would like to call a delete function while looping through a list of devices.  The devices can be one of two types - SmsPhone or Email.  Can this be achieved with one of the Java 8 FunctionalInterfaces?</p>

<pre><code>// leaving out implementation details for simplicity
public class SmsPhone extends Device {
}

public class Email extends Device {
}

public class Device {
    private String contact;
    public String getContact() { return contact; }
    public void setContact(String contact) { this.contact = contact; }
}

public class MyService {

    public void updateEmail(String username, Collection&lt;Email&gt; allEmails, Collection&lt;String&gt; selectedEmails) {
        updateUserDevices(username, allEmails, selectedEmails);
    }

    public void updateSms(String username, Collection&lt;SmsPhone&gt; allPhones, Collection&lt;String&gt; selectedPhones) {
        updateUserDevices(username, allPhones, selectedPhones);
    }

    private void updateUserDevices(final String username, Collection&lt;Device&gt; devices, Collection&lt;String&gt; contacts) {

        // put all the device contact info in the list and then filter out the ones in the given devices collection.
        devices.stream()
            .map(d -&gt; d.getContact())
            .filter(s -&gt; !contacts.contains(s))
            .forEach(s -&gt; /***Call either deleteEmail() or deleteSms()***/);
    }

    private void deleteEmail(String email) {}
    private void deleteSms(String sms) {}

}
</code></pre>