Class MovedHoliday

  • All Implemented Interfaces:
    Holiday

    public final class MovedHoliday
    extends Object
    implements Holiday
    A Holiday that has been punctually moved to another day.

    This class is useful for modeling holidays like the May Day in the United Kingdom, that has been exceptionally moved from 2020-05-04 to 2020-05-08 in 2020 to coincide with Victory in Europe Day.

    Since:
    2.1.0
    Author:
    Marc Wrobel
    • Constructor Detail

      • MovedHoliday

        public MovedHoliday​(Holiday base,
                            LocalDate... replacements)
        Create a new holiday using the given base and replacements Map.

        The replacements are expressed as k1, v1, k2, v2, ..., kn, vn where kn are the original dates dans vn are the replacement.

        Parameters:
        base - a non-null holiday to use as a base
        replacements - replacements, expressed as key / value
        Throws:
        NullPointerException - if base is null
      • MovedHoliday

        public MovedHoliday​(MonthDay base,
                            MonthDay replacement,
                            int... replacedYears)
        Create a new holiday using the given base MonthDayHoliday, the replacement day MonthDay and the years when the replacement must occur.

        This constructor build a MonthDayHoliday internally.

        Parameters:
        base - a non-null holiday to use as a base.
        replacement - the replacement expressed as a MonthDay
        replacedYears - the years when the holiday must be replaced
        Throws:
        NullPointerException - if base is null
    • Method Detail

      • 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:
        Holiday.check(LocalDate)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object