У меня есть это 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;
}
Я хочу сделать три вещи:
- используйте вместо этого @AllArgsConstructor
- и удалим конструктор
- но, конечно, соблюдайте предварительные условия
Возможно ли это?
Мне также нравится использовать шаблон @Builder, могу ли я включить предварительные условия в этот подход?