forked from nagabhushanamn/FP-in-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLambdaExtra.java
More file actions
executable file
·28 lines (23 loc) · 878 Bytes
/
Copy pathLambdaExtra.java
File metadata and controls
executable file
·28 lines (23 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.function.Predicate;
import java.util.function.Supplier;
public class LambdaExtra
{
public static void main(String ... args) {
Predicate<Manager> isGood = manager -> false;
testEmployee(emp -> false);
// compile error
// testEmployee(manager -> isGood.test(manager));
// testEmployee2(manager -> isGood.test(manager));
testEmployee((Manager manager) -> isGood.test(manager));
testEmployee2((Manager manager) -> isGood.test(manager));
}
public static Employee createEmployee(Supplier<? extends Employee> factory) {
return factory.get();
}
public static <E extends Employee> boolean testEmployee(Predicate<E> theTest) {
return theTest.test(null);
}
public static boolean testEmployee2(Predicate<? extends Employee> theTest) {
return theTest.test(null);
}
}