/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.10
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package org.quantlib;

public class ForwardRateAgreement extends Instrument {
  private transient long swigCPtr;

  protected ForwardRateAgreement(long cPtr, boolean cMemoryOwn) {
    super(QuantLibJNI.ForwardRateAgreement_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  protected static long getCPtr(ForwardRateAgreement obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        QuantLibJNI.delete_ForwardRateAgreement(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate, double notionalAmount, IborIndex index, YieldTermStructureHandle discountCurve) {
    this(QuantLibJNI.new_ForwardRateAgreement__SWIG_0(Date.getCPtr(valueDate), valueDate, Date.getCPtr(maturityDate), maturityDate, type.swigValue(), strikeForwardRate, notionalAmount, IborIndex.getCPtr(index), index, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve), true);
  }

  public ForwardRateAgreement(Date valueDate, Date maturityDate, Position.Type type, double strikeForwardRate, double notionalAmount, IborIndex index) {
    this(QuantLibJNI.new_ForwardRateAgreement__SWIG_1(Date.getCPtr(valueDate), valueDate, Date.getCPtr(maturityDate), maturityDate, type.swigValue(), strikeForwardRate, notionalAmount, IborIndex.getCPtr(index), index), true);
  }

  public double spotIncome(YieldTermStructureHandle discount) {
    return QuantLibJNI.ForwardRateAgreement_spotIncome(swigCPtr, this, YieldTermStructureHandle.getCPtr(discount), discount);
  }

  public double spotValue() {
    return QuantLibJNI.ForwardRateAgreement_spotValue(swigCPtr, this);
  }

  public InterestRate forwardRate() {
    return new InterestRate(QuantLibJNI.ForwardRateAgreement_forwardRate(swigCPtr, this), true);
  }

}
