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

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

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

  public QdPlusAmericanEngine(GeneralizedBlackScholesProcess process, long interpolationPoints, QdPlusAmericanEngine.SolverType solverType, double eps, long maxIter) {
    this(QuantLibJNI.new_QdPlusAmericanEngine__SWIG_0(GeneralizedBlackScholesProcess.getCPtr(process), process, interpolationPoints, solverType.swigValue(), eps, maxIter), true);
  }

  public QdPlusAmericanEngine(GeneralizedBlackScholesProcess process, long interpolationPoints, QdPlusAmericanEngine.SolverType solverType, double eps) {
    this(QuantLibJNI.new_QdPlusAmericanEngine__SWIG_1(GeneralizedBlackScholesProcess.getCPtr(process), process, interpolationPoints, solverType.swigValue(), eps), true);
  }

  public QdPlusAmericanEngine(GeneralizedBlackScholesProcess process, long interpolationPoints, QdPlusAmericanEngine.SolverType solverType) {
    this(QuantLibJNI.new_QdPlusAmericanEngine__SWIG_2(GeneralizedBlackScholesProcess.getCPtr(process), process, interpolationPoints, solverType.swigValue()), true);
  }

  public QdPlusAmericanEngine(GeneralizedBlackScholesProcess process, long interpolationPoints) {
    this(QuantLibJNI.new_QdPlusAmericanEngine__SWIG_3(GeneralizedBlackScholesProcess.getCPtr(process), process, interpolationPoints), true);
  }

  public QdPlusAmericanEngine(GeneralizedBlackScholesProcess process) {
    this(QuantLibJNI.new_QdPlusAmericanEngine__SWIG_4(GeneralizedBlackScholesProcess.getCPtr(process), process), true);
  }

  public final static class SolverType {
    public final static QdPlusAmericanEngine.SolverType Brent = new QdPlusAmericanEngine.SolverType("Brent");
    public final static QdPlusAmericanEngine.SolverType Newton = new QdPlusAmericanEngine.SolverType("Newton");
    public final static QdPlusAmericanEngine.SolverType Ridder = new QdPlusAmericanEngine.SolverType("Ridder");
    public final static QdPlusAmericanEngine.SolverType Halley = new QdPlusAmericanEngine.SolverType("Halley");
    public final static QdPlusAmericanEngine.SolverType SuperHalley = new QdPlusAmericanEngine.SolverType("SuperHalley");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static SolverType 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 " + SolverType.class + " with value " + swigValue);
    }

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

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

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

    private static SolverType[] swigValues = { Brent, Newton, Ridder, Halley, SuperHalley };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
