/* ----------------------------------------------------------------------------
 * 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 EquityIndex extends Index {
  private transient long swigCPtr;
  private transient boolean swigCMemOwnDerived;

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

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

  public EquityIndex(String name, Calendar fixingCalendar, YieldTermStructureHandle interest, YieldTermStructureHandle dividend, QuoteHandle spot) {
    this(QuantLibJNI.new_EquityIndex__SWIG_0(name, Calendar.getCPtr(fixingCalendar), fixingCalendar, YieldTermStructureHandle.getCPtr(interest), interest, YieldTermStructureHandle.getCPtr(dividend), dividend, QuoteHandle.getCPtr(spot), spot), true);
  }

  public EquityIndex(String name, Calendar fixingCalendar, YieldTermStructureHandle interest, YieldTermStructureHandle dividend) {
    this(QuantLibJNI.new_EquityIndex__SWIG_1(name, Calendar.getCPtr(fixingCalendar), fixingCalendar, YieldTermStructureHandle.getCPtr(interest), interest, YieldTermStructureHandle.getCPtr(dividend), dividend), true);
  }

  public EquityIndex(String name, Calendar fixingCalendar, YieldTermStructureHandle interest) {
    this(QuantLibJNI.new_EquityIndex__SWIG_2(name, Calendar.getCPtr(fixingCalendar), fixingCalendar, YieldTermStructureHandle.getCPtr(interest), interest), true);
  }

  public EquityIndex(String name, Calendar fixingCalendar) {
    this(QuantLibJNI.new_EquityIndex__SWIG_3(name, Calendar.getCPtr(fixingCalendar), fixingCalendar), true);
  }

  public YieldTermStructureHandle equityInterestRateCurve() {
    return new YieldTermStructureHandle(QuantLibJNI.EquityIndex_equityInterestRateCurve(swigCPtr, this), true);
  }

  public YieldTermStructureHandle equityDividendCurve() {
    return new YieldTermStructureHandle(QuantLibJNI.EquityIndex_equityDividendCurve(swigCPtr, this), true);
  }

  public QuoteHandle spot() {
    return new QuoteHandle(QuantLibJNI.EquityIndex_spot(swigCPtr, this), true);
  }

  public EquityIndex clone(YieldTermStructureHandle interest, YieldTermStructureHandle dividend, QuoteHandle spot) {
    long cPtr = QuantLibJNI.EquityIndex_clone(swigCPtr, this, YieldTermStructureHandle.getCPtr(interest), interest, YieldTermStructureHandle.getCPtr(dividend), dividend, QuoteHandle.getCPtr(spot), spot);
    return (cPtr == 0) ? null : new EquityIndex(cPtr, true);
  }

}
