为了账号安全,请及时绑定邮箱和手机立即绑定

Java + 龙目岛 + 番石榴 + 验证

Java + 龙目岛 + 番石榴 + 验证

红糖糍粑 2023-02-23 18:20:04
我有这个 Pojo:@Getter@EqualsAndHashCodepublic class Order {    public enum OrderType {        BUY, SELL    }    private Id id;    private Quantity quantity;    private Money price;    private OrderType orderType;    public Order(Id id, Quantity quantity, Money price, OrderType orderType) {        Preconditions.checkNotNull(id, "id can't be null");        Preconditions.checkNotNull(quantity, "quantity can't be null");        Preconditions.checkNotNull(price, "price can't be null");        Preconditions.checkNotNull(orderType, "orderType can't be null");        this.id = id;        this.quantity = quantity;        this.price = price;        this.orderType = orderType;    }我想做三件事:使用 @AllArgsConstructor 代替并删除构造函数但当然要保持先决条件这可能吗?我也喜欢使用 @Builder 模式,我可以将前提条件与这种方法结合起来吗?
查看完整描述

1 回答

?
跃然一笑

TA贡献1826条经验 获得超6个赞

标记所有字段并@lombok.NonNull使用@RequiredArgsConstructor; 应该这样做。



查看完整回答
反对 回复 2023-02-23
  • 1 回答
  • 0 关注
  • 75 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信