| 1201 | } |
| 1202 | |
| 1203 | private static class DRule<T extends ChronoEntity<T>> |
| 1204 | implements ElementRule<T, Weekday> { |
| 1205 | |
| 1206 | //~ Instanzvariablen ---------------------------------------------- |
| 1207 | |
| 1208 | final DayOfWeekElement element; |
| 1209 | |
| 1210 | //~ Konstruktoren ------------------------------------------------- |
| 1211 | |
| 1212 | private DRule(DayOfWeekElement element) { |
| 1213 | super(); |
| 1214 | |
| 1215 | this.element = element; |
| 1216 | |
| 1217 | } |
| 1218 | |
| 1219 | //~ Methoden ------------------------------------------------------ |
| 1220 | |
| 1221 | @Override |
| 1222 | public Weekday getValue(T context) { |
| 1223 | |
| 1224 | return context.get(CALENDAR_DATE).getDayOfWeek(); |
| 1225 | |
| 1226 | } |
| 1227 | |
| 1228 | @Override |
| 1229 | public Weekday getMinimum(T context) { |
| 1230 | |
| 1231 | PlainDate date = context.get(CALENDAR_DATE); |
| 1232 | int oldNum = date.getDayOfWeek().getValue(this.element.getModel()); |
| 1233 | |
| 1234 | if (date.getDaysSinceEpochUTC() + 1 - oldNum < PlainDate.axis().getCalendarSystem().getMinimumSinceUTC()) { |
| 1235 | return PlainDate.MIN.getDayOfWeek(); |
| 1236 | } |
| 1237 | |
| 1238 | return this.element.getDefaultMinimum(); |
| 1239 | |
| 1240 | } |
| 1241 | |
| 1242 | @Override |
| 1243 | public Weekday getMaximum(T context) { |
| 1244 | |
| 1245 | PlainDate date = context.get(CALENDAR_DATE); |
| 1246 | int oldNum = date.getDayOfWeek().getValue(this.element.getModel()); |
| 1247 | |
| 1248 | if (date.getDaysSinceEpochUTC() + 7 - oldNum > PlainDate.axis().getCalendarSystem().getMaximumSinceUTC()) { |
| 1249 | return PlainDate.MAX.getDayOfWeek(); |
| 1250 | } |
| 1251 | |
| 1252 | return this.element.getDefaultMaximum(); |
| 1253 | |
| 1254 | } |
| 1255 | |
| 1256 | @Override |
| 1257 | public boolean isValid( |
| 1258 | T context, |
| 1259 | Weekday value |
| 1260 | ) { |
nothing calls this directly
no outgoing calls
no test coverage detected