/* ----------------------------------------------------------------------------
 * 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 FdmSolverDesc {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

  protected FdmSolverDesc(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(FdmSolverDesc obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected static long swigRelease(FdmSolverDesc obj) {
    long ptr = 0;
    if (obj != null) {
      if (!obj.swigCMemOwn)
        throw new RuntimeException("Cannot release ownership as memory is not owned");
      ptr = obj.swigCPtr;
      obj.swigCMemOwn = false;
      obj.delete();
    }
    return ptr;
  }

  @SuppressWarnings("deprecation")
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        QuantLibJNI.delete_FdmSolverDesc(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public FdmSolverDesc(FdmMesher mesher, FdmBoundaryConditionSet bcSet, FdmStepConditionComposite condition, FdmInnerValueCalculator calculator, double maturity, long timeSteps, long dampingSteps) {
    this(QuantLibJNI.new_FdmSolverDesc(FdmMesher.getCPtr(mesher), mesher, FdmBoundaryConditionSet.getCPtr(bcSet), bcSet, FdmStepConditionComposite.getCPtr(condition), condition, FdmInnerValueCalculator.getCPtr(calculator), calculator, maturity, timeSteps, dampingSteps), true);
  }

  public FdmMesher getMesher() {
    long cPtr = QuantLibJNI.FdmSolverDesc_getMesher(swigCPtr, this);
    return (cPtr == 0) ? null : new FdmMesher(cPtr, true);
  }

  public FdmBoundaryConditionSet getBcSet() {
    return new FdmBoundaryConditionSet(QuantLibJNI.FdmSolverDesc_getBcSet(swigCPtr, this), false);
  }

  public FdmStepConditionComposite getStepConditions() {
    long cPtr = QuantLibJNI.FdmSolverDesc_getStepConditions(swigCPtr, this);
    return (cPtr == 0) ? null : new FdmStepConditionComposite(cPtr, true);
  }

  public FdmInnerValueCalculator getCalculator() {
    long cPtr = QuantLibJNI.FdmSolverDesc_getCalculator(swigCPtr, this);
    return (cPtr == 0) ? null : new FdmInnerValueCalculator(cPtr, true);
  }

  public double getMaturity() {
    return QuantLibJNI.FdmSolverDesc_getMaturity(swigCPtr, this);
  }

  public long getTimeSteps() {
    return QuantLibJNI.FdmSolverDesc_getTimeSteps(swigCPtr, this);
  }

  public long getDampingSteps() {
    return QuantLibJNI.FdmSolverDesc_getDampingSteps(swigCPtr, this);
  }

}
