Coverage Report - de.jollyday.parser.impl.EthiopianOrthodoxHolidayParser
 
Classes in this File Line Coverage Branch Coverage Complexity
EthiopianOrthodoxHolidayParser
95%
19/20
80%
8/10
8
EthiopianOrthodoxHolidayParser$1
100%
1/1
N/A
8
 
 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.parser.impl;
 17  
 
 18  
 import java.time.LocalDate;
 19  
 import java.util.Set;
 20  
 
 21  
 import de.jollyday.Holiday;
 22  
 import de.jollyday.HolidayType;
 23  
 import de.jollyday.config.EthiopianOrthodoxHoliday;
 24  
 import de.jollyday.config.Holidays;
 25  
 import de.jollyday.parser.AbstractHolidayParser;
 26  
 
 27  
 /**
 28  
  * Calculates the ethiopian orthodox holidays.
 29  
  * 
 30  
  * @author Sven Diedrichsen
 31  
  * @version $Id: $
 32  
  */
 33  2
 public class EthiopianOrthodoxHolidayParser extends AbstractHolidayParser {
 34  
 
 35  
         /**
 36  
          * Ethiopian orthodox properties prefix.
 37  
          */
 38  
         private static final String PREFIXE_PROPERTY_ETHIOPIAN_ORTHODOX = "ethiopian.orthodox.";
 39  
 
 40  
         /*
 41  
          * (non-Javadoc)
 42  
          * 
 43  
          * @see de.jollyday.parser.HolidayParser#parse(int, java.util.Set,
 44  
          * de.jollyday.config.Holidays)
 45  
          */
 46  
         /** {@inheritDoc} */
 47  
         @Override
 48  
         public void parse(int year, Set<Holiday> holidays, Holidays config) {
 49  2
                 for (EthiopianOrthodoxHoliday h : config.getEthiopianOrthodoxHoliday()) {
 50  3
                         if (!isValid(h, year)) {
 51  0
                                 continue;
 52  
                         }
 53  3
                         Set<LocalDate> ethiopianHolidays = null;
 54  3
                         switch (h.getType()) {
 55  
                         case TIMKAT:
 56  1
                                 ethiopianHolidays = calendarUtil.getEthiopianOrthodoxHolidaysInGregorianYear(year, 5, 10);
 57  1
                                 break;
 58  
                         case ENKUTATASH:
 59  1
                                 ethiopianHolidays = calendarUtil.getEthiopianOrthodoxHolidaysInGregorianYear(year, 1, 1);
 60  1
                                 break;
 61  
                         case MESKEL:
 62  1
                                 ethiopianHolidays = calendarUtil.getEthiopianOrthodoxHolidaysInGregorianYear(year, 1, 17);
 63  1
                                 break;
 64  
                         default:
 65  2
                                 throw new IllegalArgumentException("Unknown ethiopian orthodox holiday type " + h.getType());
 66  
                         }
 67  3
                         String propertiesKey = PREFIXE_PROPERTY_ETHIOPIAN_ORTHODOX + h.getType().name();
 68  3
                         HolidayType type = xmlUtil.getType(h.getLocalizedType());
 69  3
                         for (LocalDate d : ethiopianHolidays) {
 70  3
                                 holidays.add(new Holiday(d, propertiesKey, type));
 71  3
                         }
 72  3
                 }
 73  2
         }
 74  
 
 75  
 }