Re: [threeten-develop] Flexible field extensibility
Status: Alpha
Brought to you by:
scolebourne
From: Alan P. <ala...@go...> - 2012-05-29 10:35:44
|
The latest thinking of allowing a CalendricalObject as the argument for a "with()" method seems to me to be heading back towards the concept of recurrences which I understood to have been excluded from the scope of JSR-310. As I see it, a recurrence is a generator for a set of times. In a very important use case (which, being calendar-independent, makes the point simply) the recurrence generates a set of Instants. The recurrence method "matches()" returns an indication of whether a candidate is in the recurrence set or outside the set. The "next()" and "previous()" methods return the earliest (latest) time in the set no earlier (later) than a supplied starting time. The operations of recurrences can then be specified clearly as union, intersection and complement of the recurrence sets. In the context of recurrences, the direction of the adjustment is made explicit in which method ("next()" or "previous()") is being invoked on the recurrence. If providers had not been removed from the proposal, and recurrences were included, then I would have expected to have seen a "RecurrenceProvider" interface specifying a "toRecurrence()" method implemented on at least some of the ISO calendar DateTime types. Obviously once (Instant-returning) recurrences start to traffic in LocalDateTimes, there needs to be a tie-in with the GapResolver strategy classes. Looking at it from this point of view, I have to ask whether combining DateAdjuster and TimeAdjuster is going to be confusing, in that recurrences will want to couple a DateAdjuster with a TimeAdjuster under the control of a direction flag which determines whether accumulating from the TimeAdjuster into the DateAdjuster should carry or borrow the extra day when the TimeAdjuster wraps round a day boundary. Where an Adjuster is constrained by a higher order attribute being fixed and can expect lower order attributes to be unique (or uniquely-specified) in the corresponding range, there is no problem of direction. On the other hand, a completely general adjuster seems to me to be (superset of) a recurrence, and I think that it is essential to keep a clear relationship between recurrences (likely best defined on Instants and which, in a subset of cases need have nothing to do with calendars), and adjusters which have to tackle the problem of different calendar systems. If JSR-310 does not include recurrences (for which I am sure it is far too late), then I think that failing to acknowledge this point will risk encouraging ungainly recurrence systems in which the levels are confused. |