java.lang.Object
de.focus_shift.jollyday.core.Holiday
All Implemented Interfaces:
Comparable<Holiday>

public final class Holiday extends Object implements Comparable<Holiday>
Represents the holiday and contains the actual date and an localized description.
  • Constructor Details

    • Holiday

      public Holiday(@NonNull LocalDate actualDate, @Nullable String propertiesKey, @NonNull HolidayType type)
      Constructs a holiday for a date using the provided properties key to retrieve the description with.
      Parameters:
      actualDate - a LocalDate object.
      propertiesKey - a String object.
      type - a HolidayType object.
    • Holiday

      public Holiday(@NonNull LocalDate actualDate, @Nullable LocalDate observedDate, @Nullable String propertiesKey, @NonNull HolidayType type)
      Constructs a holiday for a date using the provided properties key to retrieve the description with.
      Parameters:
      actualDate - a LocalDate object.
      observedDate - a LocalDate object.
      propertiesKey - a String object.
      type - a HolidayType object.
  • Method Details

    • getDate

      public @NonNull LocalDate getDate()
      Returns the calculated holiday date.

      If the holiday is Movable and the holiday was moved, then:

      • the observed holiday date is given
      • otherwise, the actual holiday date
      Returns:
      if holiday was moved the observed date, otherwise the actual date
    • getActualDate

      public @NonNull LocalDate getActualDate()

      Returns the actual date.

      If you want the observed holiday date then use getObservedDate()

      Returns:
      the actual holiday date
    • getObservedDate

      public @NonNull Optional<LocalDate> getObservedDate()

      Getter for the field observedDate.

      Returns:
      the observed holiday date as optional
    • getPropertiesKey

      public @NonNull String getPropertiesKey()

      Getter for the field propertiesKey.

      Returns:
      the holidays properties key
    • getDescription

      public @NonNull String getDescription()
      The description read with the default locale.
      Returns:
      Description for this holiday
    • getDescription

      public @NonNull String getDescription(Locale locale)
      The description read with the provided locale.
      Parameters:
      locale - a Locale object.
      Returns:
      Description for this holiday
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • getType

      public @NonNull HolidayType getType()
      Gets the type holiday.
      Returns:
      the type holiday
    • compareTo

      public int compareTo(Holiday other)
      Compares this holiday to another holiday.

      The comparison is primarily based on the date, from earliest to latest by using the LocalDate comparator.

      Specified by:
      compareTo in interface Comparable<Holiday>
      Parameters:
      other - the other holiday to compare to, not null
      Returns:
      the comparator value, negative if less, positive if greater