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 VanillaSwap extends Swap implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable { 012 private transient long swigCPtr; 013 private transient boolean swigCMemOwnDerived; 014 015 protected VanillaSwap(long cPtr, boolean cMemoryOwn) { 016 super(QuantLibJNI.VanillaSwap_SWIGSmartPtrUpcast(cPtr), true); 017 swigCMemOwnDerived = cMemoryOwn; 018 swigCPtr = cPtr; 019 } 020 021 protected static long getCPtr(VanillaSwap obj) { 022 return (obj == null) ? 0 : obj.swigCPtr; 023 } 024 025 protected void swigSetCMemOwn(boolean own) { 026 swigCMemOwnDerived = own; 027 super.swigSetCMemOwn(own); 028 } 029 030 @SuppressWarnings("deprecation") 031 protected void finalize() { 032 delete(); 033 } 034 035 public synchronized void delete() { 036 if (swigCPtr != 0) { 037 if (swigCMemOwnDerived) { 038 swigCMemOwnDerived = false; 039 QuantLibJNI.delete_VanillaSwap(swigCPtr); 040 } 041 swigCPtr = 0; 042 } 043 super.delete(); 044 } 045 046 public VanillaSwap(Swap.Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule floatSchedule, IborIndex index, double spread, DayCounter floatingDayCount, OptionalBool withIndexedCoupons) { 047 this(QuantLibJNI.new_VanillaSwap__SWIG_0(type.swigValue(), nominal, Schedule.getCPtr(fixedSchedule), fixedSchedule, fixedRate, DayCounter.getCPtr(fixedDayCount), fixedDayCount, Schedule.getCPtr(floatSchedule), floatSchedule, IborIndex.getCPtr(index), index, spread, DayCounter.getCPtr(floatingDayCount), floatingDayCount, OptionalBool.getCPtr(withIndexedCoupons), withIndexedCoupons), true); 048 } 049 050 public VanillaSwap(Swap.Type type, double nominal, Schedule fixedSchedule, double fixedRate, DayCounter fixedDayCount, Schedule floatSchedule, IborIndex index, double spread, DayCounter floatingDayCount) { 051 this(QuantLibJNI.new_VanillaSwap__SWIG_1(type.swigValue(), nominal, Schedule.getCPtr(fixedSchedule), fixedSchedule, fixedRate, DayCounter.getCPtr(fixedDayCount), fixedDayCount, Schedule.getCPtr(floatSchedule), floatSchedule, IborIndex.getCPtr(index), index, spread, DayCounter.getCPtr(floatingDayCount), floatingDayCount), true); 052 } 053 054 public Swap.Type type() { 055 return Swap.Type.swigToEnum(QuantLibJNI.VanillaSwap_type(swigCPtr, this)); 056 } 057 058 public double fairRate() { 059 return QuantLibJNI.VanillaSwap_fairRate(swigCPtr, this); 060 } 061 062 public double fairSpread() { 063 return QuantLibJNI.VanillaSwap_fairSpread(swigCPtr, this); 064 } 065 066 public double fixedLegBPS() { 067 return QuantLibJNI.VanillaSwap_fixedLegBPS(swigCPtr, this); 068 } 069 070 public double floatingLegBPS() { 071 return QuantLibJNI.VanillaSwap_floatingLegBPS(swigCPtr, this); 072 } 073 074 public double fixedLegNPV() { 075 return QuantLibJNI.VanillaSwap_fixedLegNPV(swigCPtr, this); 076 } 077 078 public double floatingLegNPV() { 079 return QuantLibJNI.VanillaSwap_floatingLegNPV(swigCPtr, this); 080 } 081 082 public Leg fixedLeg() { 083 return new Leg(QuantLibJNI.VanillaSwap_fixedLeg(swigCPtr, this), false); 084 } 085 086 public Leg floatingLeg() { 087 return new Leg(QuantLibJNI.VanillaSwap_floatingLeg(swigCPtr, this), false); 088 } 089 090 public double nominal() { 091 return QuantLibJNI.VanillaSwap_nominal(swigCPtr, this); 092 } 093 094 public Schedule fixedSchedule() { 095 return new Schedule(QuantLibJNI.VanillaSwap_fixedSchedule(swigCPtr, this), false); 096 } 097 098 public Schedule floatingSchedule() { 099 return new Schedule(QuantLibJNI.VanillaSwap_floatingSchedule(swigCPtr, this), false); 100 } 101 102 public double fixedRate() { 103 return QuantLibJNI.VanillaSwap_fixedRate(swigCPtr, this); 104 } 105 106 public double spread() { 107 return QuantLibJNI.VanillaSwap_spread(swigCPtr, this); 108 } 109 110 public DayCounter floatingDayCount() { 111 return new DayCounter(QuantLibJNI.VanillaSwap_floatingDayCount(swigCPtr, this), false); 112 } 113 114 public DayCounter fixedDayCount() { 115 return new DayCounter(QuantLibJNI.VanillaSwap_fixedDayCount(swigCPtr, this), false); 116 } 117 118}