| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| JapaneseHolidayManager |
|
| 3.0;3 |
| 1 | /** | |
| 2 | * Copyright 2010 Sven Diedrichsen | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an | |
| 12 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | |
| 13 | * express or implied. See the License for the specific language | |
| 14 | * governing permissions and limitations under the License. | |
| 15 | */ | |
| 16 | package de.jollyday.impl; | |
| 17 | ||
| 18 | import java.time.LocalDate; | |
| 19 | import java.util.HashSet; | |
| 20 | import java.util.Set; | |
| 21 | ||
| 22 | import de.jollyday.Holiday; | |
| 23 | import de.jollyday.holidaytype.LocalizedHolidayType; | |
| 24 | ||
| 25 | /** | |
| 26 | * <p> | |
| 27 | * JapaneseHolidayManager class. | |
| 28 | * </p> | |
| 29 | * | |
| 30 | * @author Sven | |
| 31 | * @version $Id: $ | |
| 32 | */ | |
| 33 | 1 | public class JapaneseHolidayManager extends DefaultHolidayManager { |
| 34 | ||
| 35 | /** | |
| 36 | * The properties key for japanese bridging holidays. | |
| 37 | */ | |
| 38 | private static final String BRIDGING_HOLIDAY_PROPERTIES_KEY = "BRIDGING_HOLIDAY"; | |
| 39 | ||
| 40 | /** | |
| 41 | * {@inheritDoc} | |
| 42 | * | |
| 43 | * Implements the rule which requests if two holidays have one non holiday | |
| 44 | * between each other than this day is also a holiday. | |
| 45 | */ | |
| 46 | @Override | |
| 47 | public Set<Holiday> getHolidays(int year, final String... args) { | |
| 48 | 0 | Set<Holiday> holidays = super.getHolidays(year, args); |
| 49 | 0 | Set<Holiday> additionalHolidays = new HashSet<>(); |
| 50 | 0 | for (Holiday d : holidays) { |
| 51 | 0 | LocalDate twoDaysLater = d.getDate().plusDays(2); |
| 52 | 0 | if (calendarUtil.contains(holidays, twoDaysLater)) { |
| 53 | 0 | LocalDate bridgingDate = twoDaysLater.minusDays(1); |
| 54 | 0 | additionalHolidays.add(new Holiday(bridgingDate, BRIDGING_HOLIDAY_PROPERTIES_KEY, |
| 55 | LocalizedHolidayType.OFFICIAL_HOLIDAY)); | |
| 56 | } | |
| 57 | 0 | } |
| 58 | 0 | holidays.addAll(additionalHolidays); |
| 59 | 0 | return holidays; |
| 60 | } | |
| 61 | ||
| 62 | } |