aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs1810/502807/TestCollectors.java
blob: 323fb76cef3a6d482652216db34a1eaca81f8525 (plain)
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
32
33
34
35
36
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

public class TestCollectors {
    Set<Integer> ids;

    public TestCollectors(Set<Inner> inners) {
        ids = inners.stream().collect(Collectors.toList(Inner::getId));
//        ids = inners.stream().map(Inner::getId).collect(Collectors.toSet());
    } 

    public static void main() {
        Set<Inner> inners = new HashSet<>();
        inners.add(new Inner(1, "a"));
        inners.add(new Inner(1, "a"));

        new TestCollectors(inners);
    }


    public static class Inner {
        private int id;
        private String name;

        public Inner(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() { return id; }

        public String getName() { return name; }
    }
}