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 Calendar implements org.quantlib.helpers.QuantLibJNIHelpers.AutoCloseable {
012  private transient long swigCPtr;
013  protected transient boolean swigCMemOwn;
014
015  protected Calendar(long cPtr, boolean cMemoryOwn) {
016    swigCMemOwn = cMemoryOwn;
017    swigCPtr = cPtr;
018  }
019
020  protected static long getCPtr(Calendar obj) {
021    return (obj == null) ? 0 : obj.swigCPtr;
022  }
023
024  protected static long swigRelease(Calendar 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_Calendar(swigCPtr);
046      }
047      swigCPtr = 0;
048    }
049  }
050
051  public boolean isWeekend(Weekday w) {
052    return QuantLibJNI.Calendar_isWeekend(swigCPtr, this, w.swigValue());
053  }
054
055  public Date endOfMonth(Date arg0) {
056    return new Date(QuantLibJNI.Calendar_endOfMonth(swigCPtr, this, Date.getCPtr(arg0), arg0), true);
057  }
058
059  public boolean isBusinessDay(Date arg0) {
060    return QuantLibJNI.Calendar_isBusinessDay(swigCPtr, this, Date.getCPtr(arg0), arg0);
061  }
062
063  public boolean isHoliday(Date arg0) {
064    return QuantLibJNI.Calendar_isHoliday(swigCPtr, this, Date.getCPtr(arg0), arg0);
065  }
066
067  public boolean isEndOfMonth(Date arg0) {
068    return QuantLibJNI.Calendar_isEndOfMonth(swigCPtr, this, Date.getCPtr(arg0), arg0);
069  }
070
071  public void addHoliday(Date arg0) {
072    QuantLibJNI.Calendar_addHoliday(swigCPtr, this, Date.getCPtr(arg0), arg0);
073  }
074
075  public void removeHoliday(Date arg0) {
076    QuantLibJNI.Calendar_removeHoliday(swigCPtr, this, Date.getCPtr(arg0), arg0);
077  }
078
079  public Date adjust(Date d, BusinessDayConvention convention) {
080    return new Date(QuantLibJNI.Calendar_adjust__SWIG_0(swigCPtr, this, Date.getCPtr(d), d, convention.swigValue()), true);
081  }
082
083  public Date adjust(Date d) {
084    return new Date(QuantLibJNI.Calendar_adjust__SWIG_1(swigCPtr, this, Date.getCPtr(d), d), true);
085  }
086
087  public Date advance(Date d, int n, TimeUnit unit, BusinessDayConvention convention, boolean endOfMonth) {
088    return new Date(QuantLibJNI.Calendar_advance__SWIG_0(swigCPtr, this, Date.getCPtr(d), d, n, unit.swigValue(), convention.swigValue(), endOfMonth), true);
089  }
090
091  public Date advance(Date d, int n, TimeUnit unit, BusinessDayConvention convention) {
092    return new Date(QuantLibJNI.Calendar_advance__SWIG_1(swigCPtr, this, Date.getCPtr(d), d, n, unit.swigValue(), convention.swigValue()), true);
093  }
094
095  public Date advance(Date d, int n, TimeUnit unit) {
096    return new Date(QuantLibJNI.Calendar_advance__SWIG_2(swigCPtr, this, Date.getCPtr(d), d, n, unit.swigValue()), true);
097  }
098
099  public Date advance(Date d, Period period, BusinessDayConvention convention, boolean endOfMonth) {
100    return new Date(QuantLibJNI.Calendar_advance__SWIG_3(swigCPtr, this, Date.getCPtr(d), d, Period.getCPtr(period), period, convention.swigValue(), endOfMonth), true);
101  }
102
103  public Date advance(Date d, Period period, BusinessDayConvention convention) {
104    return new Date(QuantLibJNI.Calendar_advance__SWIG_4(swigCPtr, this, Date.getCPtr(d), d, Period.getCPtr(period), period, convention.swigValue()), true);
105  }
106
107  public Date advance(Date d, Period period) {
108    return new Date(QuantLibJNI.Calendar_advance__SWIG_5(swigCPtr, this, Date.getCPtr(d), d, Period.getCPtr(period), period), true);
109  }
110
111  public int businessDaysBetween(Date from, Date to, boolean includeFirst, boolean includeLast) {
112    return QuantLibJNI.Calendar_businessDaysBetween__SWIG_0(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to, includeFirst, includeLast);
113  }
114
115  public int businessDaysBetween(Date from, Date to, boolean includeFirst) {
116    return QuantLibJNI.Calendar_businessDaysBetween__SWIG_1(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to, includeFirst);
117  }
118
119  public int businessDaysBetween(Date from, Date to) {
120    return QuantLibJNI.Calendar_businessDaysBetween__SWIG_2(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to);
121  }
122
123  public DateVector holidayList(Date from, Date to, boolean includeWeekEnds) {
124    return new DateVector(QuantLibJNI.Calendar_holidayList__SWIG_0(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to, includeWeekEnds), true);
125  }
126
127  public DateVector holidayList(Date from, Date to) {
128    return new DateVector(QuantLibJNI.Calendar_holidayList__SWIG_1(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to), true);
129  }
130
131  public DateVector businessDayList(Date from, Date to) {
132    return new DateVector(QuantLibJNI.Calendar_businessDayList(swigCPtr, this, Date.getCPtr(from), from, Date.getCPtr(to), to), true);
133  }
134
135  public String name() {
136    return QuantLibJNI.Calendar_name(swigCPtr, this);
137  }
138
139  public String toString() {
140    return QuantLibJNI.Calendar_toString(swigCPtr, this);
141  }
142
143  public boolean equals(Calendar other) {
144    return QuantLibJNI.Calendar_equals(swigCPtr, this, Calendar.getCPtr(other), other);
145  }
146
147  public boolean unEquals(Calendar other) {
148    return QuantLibJNI.Calendar_unEquals(swigCPtr, this, Calendar.getCPtr(other), other);
149  }
150
151}