Class FloatingHoliday

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

public final class FloatingHoliday extends Object implements Holiday
A holiday which occurs on a different date every year. Examples of floating holidays are Diwali and Easter. Calculation of the observed date of a floating holiday can vary widely in complexity.
Author:
Dave Joyce
See Also:
  • Constructor Details

    • FloatingHoliday

      public FloatingHoliday(String name, String description, Observance observance, boolean rollable)
      Construct a new instance with explicit rollable control.
    • FloatingHoliday

      public FloatingHoliday(String name, String description, Observance observance)
      Construct a new instance that is rollable by default.
  • 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
    • getObservance

      public Observance getObservance()
    • 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