今天看spree源码的时候经常看到Object#tap方法.以前只知道有这个方法,而且感觉这个方法调试的作用大于实际,今日看来以前的理解应该不够准确. 先看下官方文档上tap的例子 Yields self to the block, and then returns self. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on int…
先定义一个实体类 @Data @AllArgsConstructor @NoArgsConstructor public class Human { private String name; private int age; } 下面的操作都基于这个类来进行操作.这里面使用了Lombok类库,它用注解的方式实现了基本的get和set等方法,让代码看起来更加的优雅. JAVA8之前的List排序操作 在Java8之前,对集合排序只能创建一个匿名内部类 new Comparator<Human>(…
原文地址:http://blog.didispace.com/java-lombok-1/ 关于Lombok,其实在网上可以找到很多如何使用的文章,但是很少能找到比较齐全的整理.我也一直寻思着想写一篇各个注解用法的总结,但是一直都没有付诸行动.今天看到了微信公众号”原力注入”推送的这篇文章,总结的内容很全,所以分享给所有关注我博客的朋友们. Lombok简介 Project Lombok makes java a spicier language by adding ‘handlers’ tha…