BAEL-2861 Fix example in Lambda Expressions article (#6696)

This commit is contained in:
kwoyke 2019-04-10 07:43:41 +02:00 committed by Grzegorz Piwowarek
parent 762e6505d4
commit c18f588f28
10 changed files with 41 additions and 39 deletions

View File

@ -1,12 +0,0 @@
package com.baeldung;
import java.util.function.Consumer;
import java.util.function.Function;
public interface Adder {
String addWithFunction(Function<String, String> f);
void addWithConsumer(Consumer<Integer> f);
}

View File

@ -1,18 +0,0 @@
package com.baeldung;
import java.util.function.Consumer;
import java.util.function.Function;
public class AdderImpl implements Adder {
@Override
public String addWithFunction(final Function<String, String> f) {
return f.apply("Something ");
}
@Override
public void addWithConsumer(final Consumer<Integer> f) {
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.java8.lambda.tips;
@FunctionalInterface

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.java8.lambda.tips;
@FunctionalInterface

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.java8.lambda.tips;
@FunctionalInterface

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.java8.lambda.tips;
@FunctionalInterface

View File

@ -0,0 +1,12 @@
package com.baeldung.java8.lambda.tips;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
public interface Processor {
String processWithCallable(Callable<String> c) throws Exception;
String processWithSupplier(Supplier<String> s);
}

View File

@ -0,0 +1,20 @@
package com.baeldung.java8.lambda.tips;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
public class ProcessorImpl implements Processor {
@Override
public String processWithCallable(Callable<String> c) throws Exception {
return c.call();
}
@Override
public String processWithSupplier(Supplier<String> s) {
return s.get();
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung;
package com.baeldung.java8.lambda.tips;
import java.util.function.Function;

View File

@ -1,8 +1,8 @@
package com.baeldung.java8;
package com.baeldung.java8.lambda.tips;
import com.baeldung.Foo;
import com.baeldung.FooExtended;
import com.baeldung.UseFoo;
import com.baeldung.java8.lambda.tips.Foo;
import com.baeldung.java8.lambda.tips.FooExtended;
import com.baeldung.java8.lambda.tips.UseFoo;
import org.junit.Before;
import org.junit.Test;