minor cleanup work
This commit is contained in:
@@ -6,11 +6,12 @@ import java.util.function.Function;
|
||||
public class AdderImpl implements Adder {
|
||||
|
||||
@Override
|
||||
public String addWithFunction(Function<String, String> f) {
|
||||
public String addWithFunction(Function<String, String> f) {
|
||||
return f.apply("Something ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWithConsumer(Consumer<Integer> f) {}
|
||||
public void addWithConsumer(Consumer<Integer> f) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,5 +5,6 @@ public interface Foo {
|
||||
|
||||
String method(String string);
|
||||
|
||||
default void defaultMethod() {}
|
||||
default void defaultMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,34 +6,32 @@ public class UseFoo {
|
||||
|
||||
private String value = "Enclosing scope value";
|
||||
|
||||
public String add(String string, Foo foo) {
|
||||
public String add(final String string, final Foo foo) {
|
||||
return foo.method(string);
|
||||
}
|
||||
|
||||
public String addWithStandardFI(String string, Function<String, String> fn) {
|
||||
public String addWithStandardFI(final String string, final Function<String, String> fn) {
|
||||
return fn.apply(string);
|
||||
}
|
||||
|
||||
public String scopeExperiment() {
|
||||
Foo fooIC = new Foo() {
|
||||
final Foo fooIC = new Foo() {
|
||||
String value = "Inner class value";
|
||||
|
||||
@Override
|
||||
public String method(String string) {
|
||||
return this.value;
|
||||
public String method(final String string) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
String resultIC = fooIC.method("");
|
||||
final String resultIC = fooIC.method("");
|
||||
|
||||
Foo fooLambda = parameter -> {
|
||||
String value = "Lambda value";
|
||||
final Foo fooLambda = parameter -> {
|
||||
final String value = "Lambda value";
|
||||
return this.value;
|
||||
};
|
||||
String resultLambda = fooLambda.method("");
|
||||
final String resultLambda = fooLambda.method("");
|
||||
|
||||
return "Results: resultIC = " + resultIC +
|
||||
", resultLambda = " + resultLambda;
|
||||
return "Results: resultIC = " + resultIC + ", resultLambda = " + resultLambda;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user