Class YearRangeHoliday

java.lang.Object
fr.marcwrobel.jbanking.calendar.YearRangeHoliday
All Implemented Interfaces:
Holiday

public final class YearRangeHoliday extends Object implements Holiday
A Holiday that is valid only for a given range or years.

This class is useful for modeling holidays like the German reformation day that was exceptionally a national holiday in 2017 because of 500 anniversary of the religious reformation in Europe.

Since:
2.1.0
  • Constructor Details

    • YearRangeHoliday

      public YearRangeHoliday(Holiday base, ValueRange validityRange)
      Create a new holiday using the given base and years of validity.
      Parameters:
      base - a non-null holiday to use as a base.
      validityRange - a non-null validity range.
      Throws:
      NullPointerException - if either base or validityRange is null
    • YearRangeHoliday

      public YearRangeHoliday(Holiday base, long from, long to)
      Create a new holiday using the given base and years of validity.
      Parameters:
      base - a non-null holiday to use as a base.
      from - the minimum year of validity (included)
      to - the maximum year of validity (included)
      Throws:
      NullPointerException - if base is null
      IllegalArgumentException - if from is greater than to
  • Method Details

    • check

      public boolean check(LocalDate date)
      Description copied from interface: Holiday
      Check whether the given date is an occurrence of this holiday.
      Specified by:
      check in interface Holiday
      Parameters:
      date - the date to check.
      Returns:
      true if the given date is an occurrence of this holiday, false otherwise.
      See Also:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object