class BillSecurityDiscountingMethod {

  public double yieldFromPriceDerivative(final BillSecurity bill, final double price) {
    if (bill.getYieldConvention() == SimpleYieldConvention.DISCOUNT) {
      return -1.0 / bill.getAccrualFactor();
    }
    if (bill.getYieldConvention() == SimpleYieldConvention.INTERESTATMTY) {
      return -1.0 / (price * price * bill.getAccrualFactor());
    }
    throw new UnsupportedOperationException("The convention " + bill.getYieldConvention().getName() + " is not supported.");
  }

  private  BillSecurityDiscountingMethod();

}