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 Exercise implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable { 012 private transient long swigCPtr; 013 private transient boolean swigCMemOwn; 014 015 protected Exercise(long cPtr, boolean cMemoryOwn) { 016 swigCMemOwn = cMemoryOwn; 017 swigCPtr = cPtr; 018 } 019 020 protected static long getCPtr(Exercise 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_Exercise(swigCPtr); 038 } 039 swigCPtr = 0; 040 } 041 } 042 043 public Exercise(Exercise.Type type) { 044 this(QuantLibJNI.new_Exercise(type.swigValue()), true); 045 } 046 047 public Exercise.Type type() { 048 return Exercise.Type.swigToEnum(QuantLibJNI.Exercise_type(swigCPtr, this)); 049 } 050 051 public Date date(long index) { 052 return new Date(QuantLibJNI.Exercise_date(swigCPtr, this, index), true); 053 } 054 055 public Date dateAt(long index) { 056 return new Date(QuantLibJNI.Exercise_dateAt(swigCPtr, this, index), true); 057 } 058 059 public DateVector dates() { 060 return new DateVector(QuantLibJNI.Exercise_dates(swigCPtr, this), false); 061 } 062 063 public Date lastDate() { 064 return new Date(QuantLibJNI.Exercise_lastDate(swigCPtr, this), true); 065 } 066 067 public Exercise.Type exerciseType() { 068 return Exercise.Type.swigToEnum(QuantLibJNI.Exercise_exerciseType(swigCPtr, this)); 069 } 070 071 public final static class Type { 072 public final static Exercise.Type American = new Exercise.Type("American"); 073 public final static Exercise.Type Bermudan = new Exercise.Type("Bermudan"); 074 public final static Exercise.Type European = new Exercise.Type("European"); 075 076 public final int swigValue() { 077 return swigValue; 078 } 079 080 public String toString() { 081 return swigName; 082 } 083 084 public static Type swigToEnum(int swigValue) { 085 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) 086 return swigValues[swigValue]; 087 for (int i = 0; i < swigValues.length; i++) 088 if (swigValues[i].swigValue == swigValue) 089 return swigValues[i]; 090 throw new IllegalArgumentException("No enum " + Type.class + " with value " + swigValue); 091 } 092 093 private Type(String swigName) { 094 this.swigName = swigName; 095 this.swigValue = swigNext++; 096 } 097 098 private Type(String swigName, int swigValue) { 099 this.swigName = swigName; 100 this.swigValue = swigValue; 101 swigNext = swigValue+1; 102 } 103 104 private Type(String swigName, Type swigEnum) { 105 this.swigName = swigName; 106 this.swigValue = swigEnum.swigValue; 107 swigNext = this.swigValue+1; 108 } 109 110 private static Type[] swigValues = { American, Bermudan, European }; 111 private static int swigNext = 0; 112 private final int swigValue; 113 private final String swigName; 114 } 115 116}