001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (https://www.swig.org).
003 * Version 4.1.1
004 *
005 * Do not make changes to this file unless you know what you are doing - modify
006 * the SWIG interface file instead.
007 * ----------------------------------------------------------------------------- */
008
009package org.quantlib;
010
011public class Callability implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable {
012  private transient long swigCPtr;
013  private transient boolean swigCMemOwn;
014
015  protected Callability(long cPtr, boolean cMemoryOwn) {
016    swigCMemOwn = cMemoryOwn;
017    swigCPtr = cPtr;
018  }
019
020  protected static long getCPtr(Callability obj) {
021    return (obj == null) ? 0 : obj.swigCPtr;
022  }
023
024  protected void swigSetCMemOwn(boolean own) {
025    swigCMemOwn = own;
026  }
027
028  @SuppressWarnings("deprecation")
029  protected void finalize() {
030    delete();
031  }
032
033  public synchronized void delete() {
034    if (swigCPtr != 0) {
035      if (swigCMemOwn) {
036        swigCMemOwn = false;
037        QuantLibJNI.delete_Callability(swigCPtr);
038      }
039      swigCPtr = 0;
040    }
041  }
042
043  public Callability(BondPrice price, Callability.Type type, Date date) {
044    this(QuantLibJNI.new_Callability(BondPrice.getCPtr(price), price, type.swigValue(), Date.getCPtr(date), date), true);
045  }
046
047  public BondPrice price() {
048    return new BondPrice(QuantLibJNI.Callability_price(swigCPtr, this), false);
049  }
050
051  public Callability.Type type() {
052    return Callability.Type.swigToEnum(QuantLibJNI.Callability_type(swigCPtr, this));
053  }
054
055  public Date date() {
056    return new Date(QuantLibJNI.Callability_date(swigCPtr, this), true);
057  }
058
059  public final static class Type {
060    public final static Callability.Type Call = new Callability.Type("Call");
061    public final static Callability.Type Put = new Callability.Type("Put");
062
063    public final int swigValue() {
064      return swigValue;
065    }
066
067    public String toString() {
068      return swigName;
069    }
070
071    public static Type swigToEnum(int swigValue) {
072      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
073        return swigValues[swigValue];
074      for (int i = 0; i < swigValues.length; i++)
075        if (swigValues[i].swigValue == swigValue)
076          return swigValues[i];
077      throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue);
078    }
079
080    private Type(String swigName) {
081      this.swigName = swigName;
082      this.swigValue = swigNext++;
083    }
084
085    private Type(String swigName, int swigValue) {
086      this.swigName = swigName;
087      this.swigValue = swigValue;
088      swigNext = swigValue+1;
089    }
090
091    private Type(String swigName, Type swigEnum) {
092      this.swigName = swigName;
093      this.swigValue = swigEnum.swigValue;
094      swigNext = this.swigValue+1;
095    }
096
097    private static Type[] swigValues = { Call, Put };
098    private static int swigNext = 0;
099    private final int swigValue;
100    private final String swigName;
101  }
102
103}