Skip to content

Commit

Permalink
Rename Official_Holiday to Public_Holiday
Browse files Browse the repository at this point in the history
and remove school and authorities holiday
  • Loading branch information
derTobsch committed Jun 13, 2024
1 parent dee6580 commit 39d8883
Show file tree
Hide file tree
Showing 48 changed files with 228 additions and 267 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,11 @@ To access the public holidays of a subdivision of a country, e.g. Baden-Württem

The following holiday types are supported:

| Type | Description |
|-------------|----------------------------------------------------------------------------------------------------------------------|
| Official | Official public holiday |
| Bank | Bank holiday, banks and offices are closed |
| School | School holiday, schools are closed |
| Authorities | Authorities are closed |
| Unofficial | Unofficial holiday that is no <br/>Bank, School or Authorities holiday <br/>(Deprecated, please use the other types) |
| Type | Description |
|------------|---------------------------------------------------------------------------------------------------------|
| Public | Public holiday |
| Bank | Bank holiday, banks and offices are closed |
| Unofficial | Unofficial holiday that is no <br/>public or bank holiday <br/>(Deprecated, please use the other types) |

## Development

Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,15 @@
package de.focus_shift.jollyday.core;

/**
* Type of holiday. Each holiday can be placed in a category and this is
* represented by this type. The categories can mark a holiday as an official
* holiday or not.
* Type of holiday.
* Each holiday can be placed in a category and this is represented by this type.
*/
public enum HolidayType {

OFFICIAL_HOLIDAY {
@Override
public boolean isOfficialHoliday() {
return true;
}
},
PUBLIC_HOLIDAY,

BANK_HOLIDAY {
@Override
public boolean isOfficialHoliday() {
return false;
}
},

SCHOOL_HOLIDAY {
@Override
public boolean isOfficialHoliday() {
return false;
}
},

AUTHORITIES_HOLIDAY {
@Override
public boolean isOfficialHoliday() {
return false;
}
},
BANK_HOLIDAY,

@Deprecated(since = "0.26.0", forRemoval = true)
UNOFFICIAL_HOLIDAY {
@Override
public boolean isOfficialHoliday() {
return false;
}
};

public abstract boolean isOfficialHoliday();

UNOFFICIAL_HOLIDAY;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Set<Holiday> getHolidays(final int year, final String... args) {
final LocalDate twoDaysLater = holiday.getDate().plusDays(2);
if (CalendarUtil.contains(holidays, twoDaysLater)) {
final LocalDate bridgingDate = twoDaysLater.minusDays(1);
additionalHolidays.add(new Holiday(bridgingDate, BRIDGING_HOLIDAY_PROPERTIES_KEY, HolidayType.OFFICIAL_HOLIDAY));
additionalHolidays.add(new Holiday(bridgingDate, BRIDGING_HOLIDAY_PROPERTIES_KEY, HolidayType.PUBLIC_HOLIDAY));
}
}
holidays.addAll(additionalHolidays);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,8 @@

<xsd:simpleType name="HolidayType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OFFICIAL_HOLIDAY"/>
<xsd:enumeration value="PUBLIC_HOLIDAY"/>
<xsd:enumeration value="BANK_HOLIDAY"/>
<xsd:enumeration value="SCHOOL_HOLIDAY"/>
<xsd:enumeration value="AUTHORITIES_HOLIDAY"/>
<xsd:enumeration value="UNOFFICIAL_HOLIDAY"/>
</xsd:restriction>
</xsd:simpleType>
Expand Down Expand Up @@ -241,7 +239,7 @@
<xsd:attribute name="validTo" type="xsd:int"/>
<xsd:attribute name="every" type="HolidayCycleType" default="EVERY_YEAR"/>
<xsd:attribute name="descriptionPropertiesKey" type="xsd:string"/>
<xsd:attribute name="localizedType" type="HolidayType" default="OFFICIAL_HOLIDAY"/>
<xsd:attribute name="localizedType" type="HolidayType" default="PUBLIC_HOLIDAY"/>
</xsd:complexType>

<xsd:simpleType name="Substituted">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.time.LocalDate;
import java.util.Locale;

import static de.focus_shift.jollyday.core.HolidayType.OFFICIAL_HOLIDAY;
import static de.focus_shift.jollyday.core.HolidayType.PUBLIC_HOLIDAY;
import static de.focus_shift.jollyday.core.HolidayType.UNOFFICIAL_HOLIDAY;
import static java.util.Locale.ENGLISH;
import static java.util.Locale.GERMAN;
Expand All @@ -15,53 +15,53 @@ class HolidayTest {

@Test
void testComparable() {
final Holiday holiday = new Holiday(LocalDate.of(2015, 1, 1), null, OFFICIAL_HOLIDAY);
final Holiday holiday = new Holiday(LocalDate.of(2015, 1, 1), null, PUBLIC_HOLIDAY);
assertThat(holiday).isInstanceOf(Comparable.class);
}

@Test
void testCompareToLess() {
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, OFFICIAL_HOLIDAY);
final Holiday christmas = new Holiday(LocalDate.of(2015, 12, 25), null, OFFICIAL_HOLIDAY);
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, PUBLIC_HOLIDAY);
final Holiday christmas = new Holiday(LocalDate.of(2015, 12, 25), null, PUBLIC_HOLIDAY);
assertThat(newYear).isLessThan(christmas);
}

@Test
void testCompareToGreater() {
final Holiday christmas = new Holiday(LocalDate.of(2015, 12, 25), null, OFFICIAL_HOLIDAY);
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, OFFICIAL_HOLIDAY);
final Holiday christmas = new Holiday(LocalDate.of(2015, 12, 25), null, PUBLIC_HOLIDAY);
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, PUBLIC_HOLIDAY);
assertThat(christmas).isGreaterThan(newYear);
}

@Test
void testCompareToEqual() {
final Holiday firstDayOfYear = new Holiday(LocalDate.of(2015, 1, 1), null, OFFICIAL_HOLIDAY);
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, OFFICIAL_HOLIDAY);
final Holiday firstDayOfYear = new Holiday(LocalDate.of(2015, 1, 1), null, PUBLIC_HOLIDAY);
final Holiday newYear = new Holiday(LocalDate.of(2015, 1, 1), null, PUBLIC_HOLIDAY);
assertThat(firstDayOfYear).isEqualByComparingTo(newYear);
}

@Test
void testHolidayDescription() {
Locale.setDefault(ENGLISH);

final Holiday holiday = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", OFFICIAL_HOLIDAY);
final Holiday holiday = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", PUBLIC_HOLIDAY);
assertThat(holiday.getDescription()).isEqualTo("Christmas");
assertThat(holiday.getDescription(GERMAN)).isEqualTo("Weihnachten");
assertThat(holiday.getDescription(new Locale("nl"))).isEqualTo("Kerstmis");
}

@Test
void testHolidayEquals() {
final Holiday h1 = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", OFFICIAL_HOLIDAY);
final Holiday h1 = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", PUBLIC_HOLIDAY);
assertThat(h1).isEqualTo(h1);

final Holiday h2b = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", OFFICIAL_HOLIDAY);
final Holiday h2b = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", PUBLIC_HOLIDAY);
assertThat(h1).isEqualTo(h2b);

final Holiday h2 = new Holiday(LocalDate.of(2011, 2, 1), "CHRISTMAS", OFFICIAL_HOLIDAY);
final Holiday h2 = new Holiday(LocalDate.of(2011, 2, 1), "CHRISTMAS", PUBLIC_HOLIDAY);
assertThat(h1).isNotEqualTo(h2);

final Holiday h3 = new Holiday(LocalDate.of(2011, 2, 2), "NEW_YEAR", OFFICIAL_HOLIDAY);
final Holiday h3 = new Holiday(LocalDate.of(2011, 2, 2), "NEW_YEAR", PUBLIC_HOLIDAY);
assertThat(h1).isNotEqualTo(h3);

final Holiday h4 = new Holiday(LocalDate.of(2011, 2, 2), "CHRISTMAS", UNOFFICIAL_HOLIDAY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public String descriptionPropertiesKey() {

@Override
public HolidayType officiality() {
return HolidayType.OFFICIAL_HOLIDAY;
return HolidayType.PUBLIC_HOLIDAY;
}
};

final Holiday holiday = new CreateHoliday(LocalDate.of(2020, 4, 1)).apply(described);

assertThat(holiday.getDate()).hasYear(2020).hasMonth(APRIL).hasDayOfMonth(1);
assertThat(holiday.getType()).isEqualTo(HolidayType.OFFICIAL_HOLIDAY);
assertThat(holiday.getType()).isEqualTo(HolidayType.PUBLIC_HOLIDAY);
assertThat(holiday.getPropertiesKey()).isEqualTo("propertiesKey");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return christianHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(christianHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return ethiopianOrthodoxHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(ethiopianOrthodoxHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayBetweenFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayBetweenFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayInMonth.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayInMonth.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayRelativeToFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayRelativeToFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return islamicHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(islamicHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToEasterSunday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToEasterSunday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToWeekdayInMonth.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToWeekdayInMonth.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void setDescriptionPropertiesKey(String value) {
*/
public HolidayType getLocalizedType() {
if (localizedType == null) {
return HolidayType.OFFICIAL_HOLIDAY;
return HolidayType.PUBLIC_HOLIDAY;
} else {
return localizedType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

public enum HolidayType {

OFFICIAL_HOLIDAY,
PUBLIC_HOLIDAY,
BANK_HOLIDAY,
SCHOOL_HOLIDAY,
AUTHORITIES_HOLIDAY,
UNOFFICIAL_HOLIDAY;

public String value() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return christianHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(christianHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return ethiopianOrthodoxHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(ethiopianOrthodoxHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayBetweenFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayBetweenFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayInMonth.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayInMonth.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return fixedWeekdayRelativeToFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(fixedWeekdayRelativeToFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return islamicHoliday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(islamicHoliday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToEasterSunday.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToEasterSunday.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToFixed.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToFixed.getLocalizedType().name());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String descriptionPropertiesKey() {
@Override
public HolidayType officiality() {
return relativeToWeekdayInMonth.getLocalizedType() == null
? HolidayType.OFFICIAL_HOLIDAY
? HolidayType.PUBLIC_HOLIDAY
: HolidayType.valueOf(relativeToWeekdayInMonth.getLocalizedType().name());
}

Expand Down
Loading

0 comments on commit 39d8883

Please sign in to comment.