forked from anton-liauchuk/java-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamTest.java
More file actions
31 lines (24 loc) · 876 Bytes
/
StreamTest.java
File metadata and controls
31 lines (24 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class StreamTest {
@Test
public void debugStream() {
StreamObject object0 = new StreamObject();
object0.setId(0);
object0.setName("0");
StreamObject object1 = new StreamObject();
object1.setId(1);
object1.setName("1");
List<StreamObject> collection = Arrays.asList(object0, object1);
// final List<Integer> collect = collection.stream()
// .filter(streamObject -> streamObject.getId() == 0)
// .map(StreamObject::getId)
// .collect(Collectors.toList());
ReferencePipeline.of(collection)
.filter(streamObject -> streamObject.getId() == 0)
.map(StreamObject::getId)
.toList();
}
}