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

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

  protected static long getCPtr(SwapIndex 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_SwapIndex(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public SwapIndex(String familyName, Period tenor, int settlementDays, Currency currency, Calendar calendar, Period fixedLegTenor, BusinessDayConvention fixedLegConvention, DayCounter fixedLegDayCounter, IborIndex iborIndex) {
    this(QuantLibJNI.new_SwapIndex__SWIG_0(familyName, Period.getCPtr(tenor), tenor, settlementDays, Currency.getCPtr(currency), currency, Calendar.getCPtr(calendar), calendar, Period.getCPtr(fixedLegTenor), fixedLegTenor, fixedLegConvention.swigValue(), DayCounter.getCPtr(fixedLegDayCounter), fixedLegDayCounter, IborIndex.getCPtr(iborIndex), iborIndex), true);
  }

  public SwapIndex(String familyName, Period tenor, int settlementDays, Currency currency, Calendar calendar, Period fixedLegTenor, BusinessDayConvention fixedLegConvention, DayCounter fixedLegDayCounter, IborIndex iborIndex, YieldTermStructureHandle discountCurve) {
    this(QuantLibJNI.new_SwapIndex__SWIG_1(familyName, Period.getCPtr(tenor), tenor, settlementDays, Currency.getCPtr(currency), currency, Calendar.getCPtr(calendar), calendar, Period.getCPtr(fixedLegTenor), fixedLegTenor, fixedLegConvention.swigValue(), DayCounter.getCPtr(fixedLegDayCounter), fixedLegDayCounter, IborIndex.getCPtr(iborIndex), iborIndex, YieldTermStructureHandle.getCPtr(discountCurve), discountCurve), true);
  }

  public Period fixedLegTenor() {
    return new Period(QuantLibJNI.SwapIndex_fixedLegTenor(swigCPtr, this), true);
  }

  public BusinessDayConvention fixedLegConvention() {
    return BusinessDayConvention.swigToEnum(QuantLibJNI.SwapIndex_fixedLegConvention(swigCPtr, this));
  }

  public IborIndex iborIndex() {
    long cPtr = QuantLibJNI.SwapIndex_iborIndex(swigCPtr, this);
    return (cPtr == 0) ? null : new IborIndex(cPtr, true);
  }

  public YieldTermStructureHandle forwardingTermStructure() {
    return new YieldTermStructureHandle(QuantLibJNI.SwapIndex_forwardingTermStructure(swigCPtr, this), true);
  }

  public YieldTermStructureHandle discountingTermStructure() {
    return new YieldTermStructureHandle(QuantLibJNI.SwapIndex_discountingTermStructure(swigCPtr, this), true);
  }

  public SwapIndex clone(YieldTermStructureHandle h) {
    long cPtr = QuantLibJNI.SwapIndex_clone__SWIG_0(swigCPtr, this, YieldTermStructureHandle.getCPtr(h), h);
    return (cPtr == 0) ? null : new SwapIndex(cPtr, true);
  }

  public SwapIndex clone(YieldTermStructureHandle forwarding, YieldTermStructureHandle discounting) {
    long cPtr = QuantLibJNI.SwapIndex_clone__SWIG_1(swigCPtr, this, YieldTermStructureHandle.getCPtr(forwarding), forwarding, YieldTermStructureHandle.getCPtr(discounting), discounting);
    return (cPtr == 0) ? null : new SwapIndex(cPtr, true);
  }

  public SwapIndex clone(Period tenor) {
    long cPtr = QuantLibJNI.SwapIndex_clone__SWIG_2(swigCPtr, this, Period.getCPtr(tenor), tenor);
    return (cPtr == 0) ? null : new SwapIndex(cPtr, true);
  }

}
