Class FixedHoliday

java.lang.Object
org.holiday.calendar.FixedHoliday
All Implemented Interfaces:
Holiday

public final class FixedHoliday extends Object implements Holiday
A holiday which occurs on the same date every year. Examples of a fixed holiday are New Year's Day and a national independence day.
Author:
Dave Joyce
  • Constructor Details

    • FixedHoliday

      public FixedHoliday(String name, String description, Month month, int dayOfMonth)
      Construct a new instance of a fixed holiday occurring on the given month and day. The constructed holiday will be rollable by default.
    • FixedHoliday

      public FixedHoliday(String name, String description, String monthAndDay)
      Construct a new instance of a fixed holiday occurring on the given month and day. The constructed holiday will be rollable by default.
    • FixedHoliday

      public FixedHoliday(String name, String description, Month month, int dayOfMonth, boolean rollable)
      Construct a new instance of a fixed holiday occurring on the given month and day, with explicit rollable control.
    • FixedHoliday

      public FixedHoliday(String name, String description, String monthAndDay, boolean rollable)
      Construct a new instance of a fixed holiday occurring on the given month and day, with explicit rollable control.
    • FixedHoliday

      public FixedHoliday(String name, String description, MonthDay monthDay, boolean rollable)
      Canonical constructor.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Holiday
      Get the name of this holiday.
      Specified by:
      getName in interface Holiday
      Returns:
      holiday name
    • getDescription

      public String getDescription()
      Description copied from interface: Holiday
      Get the description (if any) of this holiday.
      Specified by:
      getDescription in interface Holiday
      Returns:
      holiday description
    • isRollable

      public boolean isRollable()
      Description copied from interface: Holiday
      Determine if this holiday supports date rolling for actual observance on a holiday calendar.
      Specified by:
      isRollable in interface Holiday
      Returns:
      true if the date of occurrence for this holiday may be rolled for observance, false otherwise
    • getMonthDay

      public MonthDay getMonthDay()
    • getMonth

      public Month getMonth()
    • getDayOfMonth

      public int getDayOfMonth()
    • dateForYear

      public Optional<LocalDate> dateForYear(int year)
      Description copied from interface: Holiday
      Calculate the date of this holiday for the specified year. The date returned by this method may be adjusted to a different date of observance by the associated holiday calendar.
      Specified by:
      dateForYear in interface Holiday
      Parameters:
      year - full calendar year (e.g. 1977, 2021)
      Returns:
      date of this holiday, or empty if not observed on the specified year
    • 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