IDEA流式处理 Debug Stream Trace 控制面板

IDEA流式处理 Debug Stream Trace 控制面板

1、断点代码

public static void main(String[] args) {
        List<Optional<Customer>> customers = Arrays.asList(
                Optional.of(new Customer("萧炎", 18)),
                Optional.of(new Customer("林动", 22)),
                Optional.empty(),
                Optional.of(new Customer("牧尘", 21)),
                Optional.empty(),
                Optional.of(new Customer("石昊", 23)),
                Optional.empty()
        );

        long numberOf65PlusCustomers = customers
                .stream()
                .flatMap(c -> c
                        .map(Stream::of)
                        .orElseGet(Stream::empty))
                .filter(c -> c.getAge() > 18)
                .count();

        System.out.println(numberOf65PlusCustomers);
    }
public  class Customer {
        private String name;
        private Integer age;

        public Customer(String name, Integer age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Integer getAge() {
            return age;
        }

        public void setAge(Integer age) {
            this.age = age;
        }
}

2、在流式处理处打上断点
IDEA流式处理 Debug Stream Trace 控制面板_第1张图片
3、debug 运行后,点击 Stream Trace 小面板
IDEA流式处理 Debug Stream Trace 控制面板_第2张图片
4、查看面板效果
IDEA流式处理 Debug Stream Trace 控制面板_第3张图片

你可能感兴趣的:(IDEA,StreamTrace,Debug,断点)