MCPcopy Create free account
hub / github.com/annmuor/jnode / isNeedExec

Method isNeedExec

jnode-core/src/jnode/dto/Schedule.java:75–109  ·  view source on GitHub ↗
(Calendar calendar)

Source from the content-addressed store, hash-verified

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);

Callers 1

tryRunItemsByDateMethod · 0.80

Calls 7

getTypeMethod · 0.95
getDetailsMethod · 0.95
isSameHourMethod · 0.95
getLastRunDateMethod · 0.95
isSameDayMethod · 0.95
checkDetailsMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected