java.lang.Object
de.focus_shift.jollyday.core.Holiday
- All Implemented Interfaces:
Comparable<Holiday>
Represents the holiday and contains the actual date and an localized
description.
-
Constructor Summary
ConstructorsConstructorDescriptionHoliday(@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.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. -
Method Summary
Modifier and TypeMethodDescriptionintCompares this holiday to another holiday.boolean@NonNull LocalDateReturns the actual date.@NonNull LocalDategetDate()Returns the calculated holiday date.@NonNull StringThe description read with the default locale.@NonNull StringgetDescription(Locale locale) The description read with the provided locale.Getter for the fieldobservedDate.@NonNull StringGetter for the fieldpropertiesKey.@NonNull HolidayTypegetType()Gets the type holiday.inthashCode()toString()
-
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- aLocalDateobject.propertiesKey- aStringobject.type- aHolidayTypeobject.
-
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- aLocalDateobject.observedDate- aLocalDateobject.propertiesKey- aStringobject.type- aHolidayTypeobject.
-
-
Method Details
-
getDate
Returns the calculated holiday date.If the holiday is
Movableand 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
Returns the actual date.
If you want the observed holiday date then use
getObservedDate()- Returns:
- the actual holiday date
-
getObservedDate
Getter for the field
observedDate.- Returns:
- the observed holiday date as optional
-
getPropertiesKey
Getter for the field
propertiesKey.- Returns:
- the holidays properties key
-
getDescription
The description read with the default locale.- Returns:
- Description for this holiday
-
getDescription
The description read with the provided locale.- Parameters:
locale- aLocaleobject.- Returns:
- Description for this holiday
-
equals
-
hashCode
public int hashCode() -
toString
-
getType
Gets the type holiday.- Returns:
- the type holiday
-
compareTo
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:
compareToin interfaceComparable<Holiday>- Parameters:
other- the other holiday to compare to, not null- Returns:
- the comparator value, negative if less, positive if greater
-