Reputation: 2205
I have this Pojo:
@Getter
@EqualsAndHashCode
public 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;
}
I wish to do three things:
Is this possible?
I also like to use @Builder pattern, can I incorporate Preconditions with this approach?
Upvotes: 2
Views: 528
Reputation: 102953
Mark all fields with @lombok.NonNull
and use @RequiredArgsConstructor
; that should do it.
Upvotes: 2