class Product {

  private static final int DAYS_UNTIL_EXPIRATION_WHEN_DISCOUNT_ACTIVE = 4;
  private static final double DISCOUNT_RATE = 0.2;

  @NonNull private final ProductDao productDao;
  @NonNull private String name;
  @NonNull private Money price;
  @NonNull private LocalDate expirationDate;

  /**
   * Save product or update if product already exist.
   */
  public void save() {<FILL_FUNCTION_BODY>}

  /**
   * Calculate sale price of product with discount.
   */
  public Money getSalePrice() {
    return price.minus(calculateDiscount());
  }

  private Money calculateDiscount() {
    if (ChronoUnit.DAYS.between(LocalDate.now(), expirationDate)
            < DAYS_UNTIL_EXPIRATION_WHEN_DISCOUNT_ACTIVE) {

      return price.multipliedBy(DISCOUNT_RATE, RoundingMode.DOWN);
    }

    return Money.zero(USD);
  }
}

    try {
      Optional<Product> product = productDao.findByName(name);
      if (product.isPresent()) {
        productDao.update(this);
      } else {
        productDao.save(this);
      }
    } catch (SQLException ex) {
      LOGGER.error(ex.getMessage());
    }
  
<no_super_class>