class YieldSensitivityCalculator {

  public double calculatePriceForYield(final Annuity<? extends PaymentFixed> annuity, final double yield) {
    Validate.notNull(annuity, "annuity");
    double sum = 0;

    final int n = annuity.getNumberOfPayments();
    PaymentFixed temp;
    for (int i = 0; i < n; i++) {
      temp = annuity.getNthPayment(i);
      sum += temp.getAmount() * Math.exp(-yield * temp.getPaymentTime());
    }
    return sum;
  }

  private  YieldSensitivityCalculator();

}