流畅接口【其他模式】

流畅接口

@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));
    }
}
原文地址:https://www.cnblogs.com/zhuxudong/p/10223723.html