Add navigation links between time spans and transitions in TimeSpanMap
The TimeSpanMap
container provides duals views to its data.
The Span
view represent the time span during which one entry is valid, it has a value, and start and end dates.
The Transition
view represent one transition date between two spans.
The Span
view can be retrieved only for single dates, using map.getSpan(date)
, it is not possible from a span to get naturally the previous or next span, one has to use dirty tricks like map.getSpan(currentSpan.getStart().shiftedBy(-0.001))
, hoping the previous span is larger than 1ms.
The Transition
view can be retrieved only globally as a NavigableSet<Transitions>
using map.getTransitions()
. There is
no way to get the Span
on each side, only the value contained in the Span
.
The dual Span
and Transition
views are therefore mutually exclusive at API level, despite they are intertwined in the implementation.
It would be nice to have a way to get the Transition
at start and end of a Span
, and to have the before and after Spans
at both sides of a Transition
. It would also be nice to have next
and previous
methods to navigated from one Transition
to the other or to one Span
to the other.