/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 4.0.2
 *
 * 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 SwapSpreadIndex extends InterestRateIndex {
  private transient long swigCPtr;
  private transient boolean swigCMemOwnDerived;

  protected SwapSpreadIndex(long cPtr, boolean cMemoryOwn) {
    super(QuantLibJNI.SwapSpreadIndex_SWIGSmartPtrUpcast(cPtr), true);
    swigCMemOwnDerived = cMemoryOwn;
    swigCPtr = cPtr;
  }

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

  protected void swigSetCMemOwn(boolean own) {
    swigCMemOwnDerived = own;
    super.swigSetCMemOwn(own);
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

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

  public SwapSpreadIndex(String familyName, SwapIndex swapIndex1, SwapIndex swapIndex2, double gearing1, double gearing2) {
    this(QuantLibJNI.new_SwapSpreadIndex__SWIG_0(familyName, SwapIndex.getCPtr(swapIndex1), swapIndex1, SwapIndex.getCPtr(swapIndex2), swapIndex2, gearing1, gearing2), true);
  }

  public SwapSpreadIndex(String familyName, SwapIndex swapIndex1, SwapIndex swapIndex2, double gearing1) {
    this(QuantLibJNI.new_SwapSpreadIndex__SWIG_1(familyName, SwapIndex.getCPtr(swapIndex1), swapIndex1, SwapIndex.getCPtr(swapIndex2), swapIndex2, gearing1), true);
  }

  public SwapSpreadIndex(String familyName, SwapIndex swapIndex1, SwapIndex swapIndex2) {
    this(QuantLibJNI.new_SwapSpreadIndex__SWIG_2(familyName, SwapIndex.getCPtr(swapIndex1), swapIndex1, SwapIndex.getCPtr(swapIndex2), swapIndex2), true);
  }

  public double forecastFixing(Date fixingDate) {
    return QuantLibJNI.SwapSpreadIndex_forecastFixing(swigCPtr, this, Date.getCPtr(fixingDate), fixingDate);
  }

  public double pastFixing(Date fixingDate) {
    return QuantLibJNI.SwapSpreadIndex_pastFixing(swigCPtr, this, Date.getCPtr(fixingDate), fixingDate);
  }

  public SwapIndex swapIndex1() {
    long cPtr = QuantLibJNI.SwapSpreadIndex_swapIndex1(swigCPtr, this);
    return (cPtr == 0) ? null : new SwapIndex(cPtr, true);
  }

  public SwapIndex swapIndex2() {
    long cPtr = QuantLibJNI.SwapSpreadIndex_swapIndex2(swigCPtr, this);
    return (cPtr == 0) ? null : new SwapIndex(cPtr, true);
  }

  public double gearing1() {
    return QuantLibJNI.SwapSpreadIndex_gearing1(swigCPtr, this);
  }

  public double gearing2() {
    return QuantLibJNI.SwapSpreadIndex_gearing2(swigCPtr, this);
  }

}
