package de.egga.higher_order_java.introduction;

import java.util.List;

import static java.util.Arrays.asList;

/**
 * @author egga
 */
public class Lambdas {

    public void showMeTheMoney() {
        List<SuperVillain> superVillains = asList(new SuperVillain("Sheldon Cooper"));

        superVillains.removeIf(sv -> sv.hasBeenDefeated());
        superVillains.forEach(SuperVillain::evilLaugh);
    }

    private class SuperVillain {

        public SuperVillain(String name) {
        }

        public boolean hasBeenDefeated() {
            return true || false;
        }

        public void evilLaugh() {

        }
    }
}

@@ -64,16 +64,53 @@
 il.List;
+%0Aimport java.util.function.Predicate;
 %0A%0Aimport
@@ -429,16 +429,144 @@
 lLaugh);
+%0A%0A        Predicate%3CSuperVillain%3E needed%0A                = s -%3E s.canSaveUsNow();%0A        superVillains.stream().filter(needed);
 %0A    %7D%0A%0A
@@ -785,16 +785,101 @@
        %7D
+%0A%0A        public boolean canSaveUsNow() %7B%0A            return true %7C%7C false;%0A        %7D
 %0A    %7D%0A%7D

add example of assigned lambda