BAEL-3722: Sync article and the code (#9897)

This commit is contained in:
kwoyke 2020-08-19 14:27:29 +02:00 committed by GitHub
parent 00e8b70870
commit c9e9ff79e9
4 changed files with 15 additions and 9 deletions

View File

@ -6,8 +6,11 @@ public interface Bar {
String method(String string);
default String defaultMethod() {
return "String from Bar";
default String defaultBar() {
return "Default String from Bar";
}
default String defaultCommon() {
return "Default Common from Bar";
}
}

View File

@ -6,7 +6,11 @@ public interface Baz {
String method(String string);
default String defaultMethod() {
return "String from Baz";
default String defaultBaz() {
return "Default String from Baz";
}
default String defaultCommon(){
return "Default Common from Baz";
}
}

View File

@ -5,8 +5,7 @@ package com.baeldung.java8.lambda.tips;
public interface FooExtended extends Baz, Bar {
@Override
default String defaultMethod() {
return Bar.super.defaultMethod();
default String defaultCommon() {
return Bar.super.defaultCommon();
}
}

View File

@ -39,9 +39,9 @@ public class Java8FunctionalInteracesLambdasUnitTest {
@Test
public void defaultMethodFromExtendedInterface_whenReturnDefiniteString_thenCorrect() {
final FooExtended fooExtended = string -> string;
final String result = fooExtended.defaultMethod();
final String result = fooExtended.defaultCommon();
assertEquals("String from Bar", result);
assertEquals("Default Common from Bar", result);
}
@Test