历史文章:
- OGNL语法规范
- 消失的堆栈
- Arthas原理系列(一):利用JVM的attach机制实现一个极简的watch命令
- Arthas原理系列(二):总体架构和项目入口
- Arthas原理系列(三):服务端启动流程
- Arthas原理系列(四):字节码插装让一切变得有可能
- Arthas原理系列(五):watch命令的实现原理
相信Lombok插件大家一定不会陌生,一个常用的注解是:@Builer
, 它可以帮我们快速实现一个builder
模式。以常见的商品模型为例:
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ItemDTO {
/**
* 商品ID
*/
private Long itemId;
/**
* 商品标题
*/
private String itemTitle;
/**
* 商品原价,单位是分
*/
private Long price;
/**
* 商品优惠价,单位是分
*/
private Long promotionPrice;
}
一行代码就可以构造出一个新的商品:
ItemDTO itemDTO = ItemDTO.builder()
.itemId(6542744309L)
.itemTitle("测试请不要拍小番茄500g/盒")
.price(500L)
.