[BAEL-3392] Formatted code examples for [BAEL-3392]

This commit is contained in:
Martin van Wingerden
2019-11-01 09:05:12 +01:00
parent b264937ac6
commit af3b4b8a5f
2 changed files with 22 additions and 22 deletions

View File

@@ -1,10 +1,10 @@
package com.baeldung.streams.debug;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.stream.IntStream;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class Example1 {
@Test

View File

@@ -1,14 +1,15 @@
package com.baeldung.streams.debug;
import com.baeldung.streams.debug.entity.Customer;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import com.baeldung.streams.debug.entity.Customer;
public class Example2 {
@Test
@@ -20,12 +21,11 @@ public class Example2 {
Optional.of(new Customer("Mary T.", 20)),
Optional.empty(),
Optional.of(new Customer("Florian G.", 89)),
Optional.empty());
Optional.empty()
);
long numberOf65PlusCustomers = customers
.stream()
.flatMap(c -> c
.map(Stream::of)
long numberOf65PlusCustomers = customers.stream()
.flatMap(c -> c.map(Stream::of)
.orElseGet(Stream::empty))
.mapToInt(Customer::getAge)
.filter(c -> c > 65)