Skip to content

Commit 414add4

Browse files
committed
Add example for anonymous implementation of callback
1 parent d301105 commit 414add4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/test/java/de/codecentric/java8examples/methodreference/MethodReferenceExampleTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ public void setUp() throws Exception {
2020
}
2121

2222
@Test
23-
public void methodReferencToFooMethod() throws Exception {
23+
public void callbackWithoutMethodReference() throws Exception {
24+
Callable<String> callable = new Callable<String>() {
25+
@Override
26+
public String call() throws Exception {
27+
return myFoo.doSomething();
28+
}
29+
};
30+
31+
assertEquals(myFoo.doSomething(), callable.call());
32+
}
33+
34+
@Test
35+
public void callbackWithMethodReference() throws Exception {
2436
Callable<String> callable = myFoo::doSomething;
2537

2638
assertEquals(myFoo.doSomething(), callable.call());

0 commit comments

Comments
 (0)