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

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

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

  public Swaption(VanillaSwap swap, Exercise exercise, Settlement.Type type, Settlement.Method settlementMethod) {
    this(QuantLibJNI.new_Swaption__SWIG_0(VanillaSwap.getCPtr(swap), swap, Exercise.getCPtr(exercise), exercise, type.swigValue(), settlementMethod.swigValue()), true);
  }

  public Swaption(VanillaSwap swap, Exercise exercise, Settlement.Type type) {
    this(QuantLibJNI.new_Swaption__SWIG_1(VanillaSwap.getCPtr(swap), swap, Exercise.getCPtr(exercise), exercise, type.swigValue()), true);
  }

  public Swaption(VanillaSwap swap, Exercise exercise) {
    this(QuantLibJNI.new_Swaption__SWIG_2(VanillaSwap.getCPtr(swap), swap, Exercise.getCPtr(exercise), exercise), true);
  }

  public Settlement.Type settlementType() {
    return Settlement.Type.swigToEnum(QuantLibJNI.Swaption_settlementType(swigCPtr, this));
  }

  public Settlement.Method settlementMethod() {
    return Settlement.Method.swigToEnum(QuantLibJNI.Swaption_settlementMethod(swigCPtr, this));
  }

  public VanillaSwap.Type type() {
    return VanillaSwap.Type.swigToEnum(QuantLibJNI.Swaption_type(swigCPtr, this));
  }

  public VanillaSwap underlyingSwap() {
    long cPtr = QuantLibJNI.Swaption_underlyingSwap(swigCPtr, this);
    return (cPtr == 0) ? null : new VanillaSwap(cPtr, true);
  }

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

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

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

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

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

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

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

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

  public double delta() {
    return QuantLibJNI.Swaption_delta(swigCPtr, this);
  }

  public double annuity() {
    return QuantLibJNI.Swaption_annuity(swigCPtr, this);
  }

}
