我有這個 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 代替并刪除構(gòu)造函數(shù)但當然要保持先決條件這可能嗎?我也喜歡使用 @Builder 模式,我可以將前提條件與這種方法結(jié)合起來嗎?
添加回答
舉報
0/150
提交
取消