private static boolean _isValidForCycle ( @ Nonnull final Holiday aHoliday , final int nYear ) { final String sEvery = aHoliday . getEvery ( ) ; if ( sEvery != null && ! "EVERY_YEAR" . equals ( sEvery ) ) { if ( "ODD_YEARS" . equals ( sEvery ) ) return nYear % 2 != 0 ; if ( "EVEN_YEARS" . equals ( sEvery ) ) return nYear % 2 == 0 ; if ( aHoliday . getValidFrom ( ) != null ) { int nCycleYears = 0 ; if ( "2_YEARS" . equalsIgnoreCase ( sEvery ) ) nCycleYears = 2 ; else if ( "3_YEARS" . equalsIgnoreCase ( sEvery ) ) nCycleYears = 3 ; else if ( "4_YEARS" . equalsIgnoreCase ( sEvery ) ) nCycleYears = 4 ; else if ( "5_YEARS" . equalsIgnoreCase ( sEvery ) ) nCycleYears = 5 ; else if ( "6_YEARS" . equalsIgnoreCase ( sEvery ) ) nCycleYears = 6 ; else throw new IllegalArgumentException ( "Cannot handle unknown cycle type '" + sEvery + "'." ) ; return ( nYear - aHoliday . getValidFrom ( ) . intValue ( ) ) % nCycleYears == 0 ; } } return true ; }
Checks cyclic holidays and checks if the requested year is hit within the cycles .