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 InterestRate implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable { 012 private transient long swigCPtr; 013 protected transient boolean swigCMemOwn; 014 015 protected InterestRate(long cPtr, boolean cMemoryOwn) { 016 swigCMemOwn = cMemoryOwn; 017 swigCPtr = cPtr; 018 } 019 020 protected static long getCPtr(InterestRate obj) { 021 return (obj == null) ? 0 : obj.swigCPtr; 022 } 023 024 protected static long swigRelease(InterestRate obj) { 025 long ptr = 0; 026 if (obj != null) { 027 if (!obj.swigCMemOwn) 028 throw new RuntimeException("Cannot release ownership as memory is not owned"); 029 ptr = obj.swigCPtr; 030 obj.swigCMemOwn = false; 031 obj.delete(); 032 } 033 return ptr; 034 } 035 036 @SuppressWarnings("deprecation") 037 protected void finalize() { 038 delete(); 039 } 040 041 public synchronized void delete() { 042 if (swigCPtr != 0) { 043 if (swigCMemOwn) { 044 swigCMemOwn = false; 045 QuantLibJNI.delete_InterestRate(swigCPtr); 046 } 047 swigCPtr = 0; 048 } 049 } 050 051 public InterestRate() { 052 this(QuantLibJNI.new_InterestRate__SWIG_0(), true); 053 } 054 055 public InterestRate(double r, DayCounter dc, Compounding comp, Frequency freq) { 056 this(QuantLibJNI.new_InterestRate__SWIG_1(r, DayCounter.getCPtr(dc), dc, comp.swigValue(), freq.swigValue()), true); 057 } 058 059 public double rate() { 060 return QuantLibJNI.InterestRate_rate(swigCPtr, this); 061 } 062 063 public DayCounter dayCounter() { 064 return new DayCounter(QuantLibJNI.InterestRate_dayCounter(swigCPtr, this), true); 065 } 066 067 public Compounding compounding() { 068 return Compounding.swigToEnum(QuantLibJNI.InterestRate_compounding(swigCPtr, this)); 069 } 070 071 public Frequency frequency() { 072 return Frequency.swigToEnum(QuantLibJNI.InterestRate_frequency(swigCPtr, this)); 073 } 074 075 public double discountFactor(double t) { 076 return QuantLibJNI.InterestRate_discountFactor__SWIG_0(swigCPtr, this, t); 077 } 078 079 public double discountFactor(Date d1, Date d2, Date refStart, Date refEnd) { 080 return QuantLibJNI.InterestRate_discountFactor__SWIG_1(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart, Date.getCPtr(refEnd), refEnd); 081 } 082 083 public double discountFactor(Date d1, Date d2, Date refStart) { 084 return QuantLibJNI.InterestRate_discountFactor__SWIG_2(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart); 085 } 086 087 public double discountFactor(Date d1, Date d2) { 088 return QuantLibJNI.InterestRate_discountFactor__SWIG_3(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2); 089 } 090 091 public double compoundFactor(double t) { 092 return QuantLibJNI.InterestRate_compoundFactor__SWIG_0(swigCPtr, this, t); 093 } 094 095 public double compoundFactor(Date d1, Date d2, Date refStart, Date refEnd) { 096 return QuantLibJNI.InterestRate_compoundFactor__SWIG_1(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart, Date.getCPtr(refEnd), refEnd); 097 } 098 099 public double compoundFactor(Date d1, Date d2, Date refStart) { 100 return QuantLibJNI.InterestRate_compoundFactor__SWIG_2(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart); 101 } 102 103 public double compoundFactor(Date d1, Date d2) { 104 return QuantLibJNI.InterestRate_compoundFactor__SWIG_3(swigCPtr, this, Date.getCPtr(d1), d1, Date.getCPtr(d2), d2); 105 } 106 107 public static InterestRate impliedRate(double compound, DayCounter resultDC, Compounding comp, Frequency freq, double t) { 108 return new InterestRate(QuantLibJNI.InterestRate_impliedRate__SWIG_0(compound, DayCounter.getCPtr(resultDC), resultDC, comp.swigValue(), freq.swigValue(), t), true); 109 } 110 111 public static InterestRate impliedRate(double compound, DayCounter resultDC, Compounding comp, Frequency freq, Date d1, Date d2, Date refStart, Date refEnd) { 112 return new InterestRate(QuantLibJNI.InterestRate_impliedRate__SWIG_1(compound, DayCounter.getCPtr(resultDC), resultDC, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart, Date.getCPtr(refEnd), refEnd), true); 113 } 114 115 public static InterestRate impliedRate(double compound, DayCounter resultDC, Compounding comp, Frequency freq, Date d1, Date d2, Date refStart) { 116 return new InterestRate(QuantLibJNI.InterestRate_impliedRate__SWIG_2(compound, DayCounter.getCPtr(resultDC), resultDC, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart), true); 117 } 118 119 public static InterestRate impliedRate(double compound, DayCounter resultDC, Compounding comp, Frequency freq, Date d1, Date d2) { 120 return new InterestRate(QuantLibJNI.InterestRate_impliedRate__SWIG_3(compound, DayCounter.getCPtr(resultDC), resultDC, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2), true); 121 } 122 123 public InterestRate equivalentRate(Compounding comp, Frequency freq, double t) { 124 return new InterestRate(QuantLibJNI.InterestRate_equivalentRate__SWIG_0(swigCPtr, this, comp.swigValue(), freq.swigValue(), t), true); 125 } 126 127 public InterestRate equivalentRate(DayCounter resultDayCounter, Compounding comp, Frequency freq, Date d1, Date d2, Date refStart, Date refEnd) { 128 return new InterestRate(QuantLibJNI.InterestRate_equivalentRate__SWIG_1(swigCPtr, this, DayCounter.getCPtr(resultDayCounter), resultDayCounter, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart, Date.getCPtr(refEnd), refEnd), true); 129 } 130 131 public InterestRate equivalentRate(DayCounter resultDayCounter, Compounding comp, Frequency freq, Date d1, Date d2, Date refStart) { 132 return new InterestRate(QuantLibJNI.InterestRate_equivalentRate__SWIG_2(swigCPtr, this, DayCounter.getCPtr(resultDayCounter), resultDayCounter, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2, Date.getCPtr(refStart), refStart), true); 133 } 134 135 public InterestRate equivalentRate(DayCounter resultDayCounter, Compounding comp, Frequency freq, Date d1, Date d2) { 136 return new InterestRate(QuantLibJNI.InterestRate_equivalentRate__SWIG_3(swigCPtr, this, DayCounter.getCPtr(resultDayCounter), resultDayCounter, comp.swigValue(), freq.swigValue(), Date.getCPtr(d1), d1, Date.getCPtr(d2), d2), true); 137 } 138 139 public String toString() { 140 return QuantLibJNI.InterestRate_toString(swigCPtr, this); 141 } 142 143}