流畅接口【其他模式】

流畅接口

@Slf4j
@SuppressWarnings("boxing")
public class FlentInterface {
    /**
     * Fluent Interface pattern【流畅接口】:能够提供易读、流畅的编程模式
     */
    @Test
    public void all() {
        Stream.of(1, 2, 3)
        .filter(x -> x >= 2)
        .limit(1)
        .findAny()
        .ifPresent(val -> log.info("{}", val));
    }
}

posted on 2019-01-05 11:15  竺旭东  阅读(96)  评论(0编辑  收藏  举报

导航