public Map<String, JollyHoliday> getAllHolidaysMap(Set<de.jollyday.config.Holiday> allHolidays) { Map<String, JollyHoliday> map = Generics.newHashMap(); for (de.jollyday.config.Holiday h : allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.put(jh.label, jh); } } return map; }
/** * Checks whether the holiday is within the valid date range. * * @param h the holiday to check for validity * @param year the year to check the holiday to be valid in * @return the holiday is valid */ private <T extends Holiday> boolean isValidInYear(T h, int year) { return (h.getValidFrom() == null || h.getValidFrom() <= year) && (h.getValidTo() == null || h.getValidTo() >= year); }
if (h.getEvery() != null) { if (!EVERY_YEAR.equals(h.getEvery())) { if (ODD_YEARS.equals(h.getEvery())) { return year % 2 != 0; } else if (EVEN_YEARS.equals(h.getEvery())) { return year % 2 == 0; } else { if (h.getValidFrom() != null) { int cycleYears; if (TWO_YEARS.equalsIgnoreCase(h.getEvery())) { cycleYears = 2; } else if (THREE_YEARS.equalsIgnoreCase(h.getEvery())) { cycleYears = 3; } else if (FOUR_YEARS.equalsIgnoreCase(h.getEvery())) { cycleYears = 4; } else if (FIVE_YEARS.equalsIgnoreCase(h.getEvery())) { cycleYears = 5; } else if (SIX_YEARS.equalsIgnoreCase(h.getEvery())) { cycleYears = 6; } else { throw new IllegalArgumentException("Cannot handle unknown cycle type '" + h.getEvery() + "'."); return (year - h.getValidFrom()) % cycleYears == 0;
public CollectionValuedMap<String, JollyHoliday> getAllHolidaysCVMap(Set<de.jollyday.config.Holiday> allHolidays) { CollectionValuedMap<String, JollyHoliday> map = new CollectionValuedMap<>(); for (de.jollyday.config.Holiday h:allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.add(jh.label, jh); } } return map; }
private SUTime.Time resolveWithYear(int year) { // TODO: If we knew location of article, can use that information to resolve holidays better Set<de.jollyday.Holiday> holidays = holidayManager.getHolidays(year); // Try to find this holiday for (de.jollyday.Holiday h : holidays) { if (h.getPropertiesKey().equals(base.getDescriptionPropertiesKey())) { return new SUTime.PartialTime(this, new Partial(h.getDate())); } } return null; }
public Map<String, JollyHoliday> getAllHolidaysMap(Set<de.jollyday.config.Holiday> allHolidays) { Map<String, JollyHoliday> map = Generics.newHashMap(); for (de.jollyday.config.Holiday h : allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.put(jh.label, jh); } } return map; }
public Map<String, JollyHoliday> getAllHolidaysMap(Set<de.jollyday.config.Holiday> allHolidays) { Map<String, JollyHoliday> map = Generics.newHashMap(); for (de.jollyday.config.Holiday h:allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.put(jh.label, jh); } } return map; }
public CollectionValuedMap<String, JollyHoliday> getAllHolidaysCVMap(Set<de.jollyday.config.Holiday> allHolidays) { CollectionValuedMap<String, JollyHoliday> map = new CollectionValuedMap<>(); for (de.jollyday.config.Holiday h:allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.add(jh.label, jh); } } return map; }
public CollectionValuedMap<String, JollyHoliday> getAllHolidaysCVMap(Set<de.jollyday.config.Holiday> allHolidays) { CollectionValuedMap<String, JollyHoliday> map = new CollectionValuedMap<String, JollyHoliday>(); for (de.jollyday.config.Holiday h:allHolidays) { String descKey = h.getDescriptionPropertiesKey(); if (descKey != null) { descKey = descKey.replaceAll(".*\\.",""); JollyHoliday jh = new JollyHoliday(descKey, holidayManager, h); map.add(jh.label, jh); } } return map; }
private SUTime.Time resolveWithYear(int year) { // TODO: If we knew location of article, can use that information to resolve holidays better Set<de.jollyday.Holiday> holidays = holidayManager.getHolidays(year); // Try to find this holiday for (de.jollyday.Holiday h : holidays) { if (h.getPropertiesKey().equals(base.getDescriptionPropertiesKey())) { return new SUTime.PartialTime(this, new Partial(h.getDate())); } } return null; }
@Override public SUTime.Time resolve(SUTime.Time t, int flags) { Partial p = (t != null)? t.getJodaTimePartial():null; if (p != null) { if (JodaTimeUtils.hasField(p, DateTimeFieldType.year())) { int year = p.get(DateTimeFieldType.year()); // TODO: If we knew location of article, can use that information to resolve holidays better Set<de.jollyday.Holiday> holidays = holidayManager.getHolidays(year); // Try to find this holiday for (de.jollyday.Holiday h:holidays) { if (h.getPropertiesKey().equals(base.getDescriptionPropertiesKey())) { return new SUTime.PartialTime(this, new Partial(h.getDate())); } } } } return this; }