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

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

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

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, long maxEvaluations, double minVol, double maxVol, VolatilityType type, double displacement) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_0(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy, maxEvaluations, minVol, maxVol, type.swigValue(), displacement);
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, long maxEvaluations, double minVol, double maxVol, VolatilityType type) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_1(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy, maxEvaluations, minVol, maxVol, type.swigValue());
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, long maxEvaluations, double minVol, double maxVol) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_2(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy, maxEvaluations, minVol, maxVol);
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, long maxEvaluations, double minVol) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_3(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy, maxEvaluations, minVol);
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy, long maxEvaluations) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_4(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy, maxEvaluations);
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess, double accuracy) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_5(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess, accuracy);
  }

  public double impliedVolatility(double price, YieldTermStructureHandle disc, double guess) {
    return QuantLibJNI.CapFloor_impliedVolatility__SWIG_6(swigCPtr, this, price, YieldTermStructureHandle.getCPtr(disc), disc, guess);
  }

  public Leg floatingLeg() {
    return new Leg(QuantLibJNI.CapFloor_floatingLeg(swigCPtr, this), false);
  }

  public DoubleVector capRates() {
    return new DoubleVector(QuantLibJNI.CapFloor_capRates(swigCPtr, this), false);
  }

  public DoubleVector floorRates() {
    return new DoubleVector(QuantLibJNI.CapFloor_floorRates(swigCPtr, this), false);
  }

  public Date startDate() {
    return new Date(QuantLibJNI.CapFloor_startDate(swigCPtr, this), true);
  }

  public Date maturityDate() {
    return new Date(QuantLibJNI.CapFloor_maturityDate(swigCPtr, this), true);
  }

  public CapFloor.Type type() {
    return CapFloor.Type.swigToEnum(QuantLibJNI.CapFloor_type(swigCPtr, this));
  }

  public double atmRate(YieldTermStructure discountCurve) {
    return QuantLibJNI.CapFloor_atmRate(swigCPtr, this, YieldTermStructure.getCPtr(discountCurve), discountCurve);
  }

  public double vega() {
    return QuantLibJNI.CapFloor_vega(swigCPtr, this);
  }

  public DoubleVector optionletsPrice() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsPrice(swigCPtr, this), true);
  }

  public DoubleVector optionletsVega() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsVega(swigCPtr, this), true);
  }

  public DoubleVector optionletsDelta() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsDelta(swigCPtr, this), true);
  }

  public DoubleVector optionletsDiscountFactor() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsDiscountFactor(swigCPtr, this), true);
  }

  public DoubleVector optionletsAtmForward() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsAtmForward(swigCPtr, this), true);
  }

  public DoubleVector optionletsStdDev() {
    return new DoubleVector(QuantLibJNI.CapFloor_optionletsStdDev(swigCPtr, this), true);
  }

  public final static class Type {
    public final static CapFloor.Type Cap = new CapFloor.Type("Cap");
    public final static CapFloor.Type Floor = new CapFloor.Type("Floor");
    public final static CapFloor.Type Collar = new CapFloor.Type("Collar");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static Type swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue);
    }

    private Type(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private Type(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private Type(String swigName, Type swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static Type[] swigValues = { Cap, Floor, Collar };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
