(Calendar calendar)
| 73 | } |
| 74 | |
| 75 | public boolean isNeedExec(Calendar calendar) { |
| 76 | |
| 77 | if (calendar == null || getType() == null || getDetails() == null) { |
| 78 | return false; |
| 79 | } |
| 80 | |
| 81 | switch (getType()) { |
| 82 | case HOURLY: |
| 83 | if (isSameHour(getLastRunDate(), new Date())) { |
| 84 | return false; |
| 85 | } |
| 86 | break; |
| 87 | default: |
| 88 | if (isSameDay(getLastRunDate(), new Date())) { |
| 89 | return false; |
| 90 | } |
| 91 | break; |
| 92 | } |
| 93 | |
| 94 | switch (getType()) { |
| 95 | case HOURLY: |
| 96 | return true; |
| 97 | case DAILY: |
| 98 | return checkDetails(calendar.get(Calendar.HOUR_OF_DAY)); |
| 99 | case ANNUALLY: |
| 100 | return checkDetails(calendar.get(Calendar.DAY_OF_YEAR)); |
| 101 | case MONTHLY: |
| 102 | return checkDetails(calendar.get(Calendar.DAY_OF_MONTH)); |
| 103 | case WEEKLY: |
| 104 | return checkDetails(calendar.get(Calendar.DAY_OF_WEEK)); |
| 105 | |
| 106 | default: |
| 107 | return false; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | private boolean checkDetails(int fromCalendar) { |
| 112 | return getDetails() != null && getDetails().equals(fromCalendar); |
no test coverage detected