람다표현식
Predicate<T>
boolean text (T t);
만 지정되어 있다.@Functional Interface
() -> void
(Apple, Apple) -> int
동작 파라미터화
를 기억!boolean test
)void accept
)R apply
)(Apple a) -> a.getWeight()
-> Apple::getWeight
Function<String, Integer> stringToInteger
(String s) -> Integer.parseInt(s)
Integer::parseInt;
BiPredicate<List<String>, String>> contains
(list, element) -> list.contains(element)
List::contains;
Predicate<String> startsWithNumber
(String string) -> this.startsWithNumber(string)
this::startsWithNumber
Apple(Integer weight)
시그니처를 갖는 생성자가 있다면Function<Integer, Apple> c2 = Apple::new;
Apple a2 = c2.apply(110);
Function<Integer, Apple> c2 = (weight) -> new Apple(weight);
Apple a2 = c2.apply(110);
inventory.sort(Comparator.comparing(Apple::getWeight).reversed());
inventory.sort(Comparator.comparing(Apple::getWeight)
.reversed()
.thenComparing(Apple::getCountry));
Predicate<Apple> notRedApple = redApple.negate();
Predicate<Apple> redAndHeavyApple = redApple.and(apple -> apple.getWeight() > 150);