[threeten-dev] [threeten-develop] TemporalAdder and TemporalSubtractor
Stephen Colebourne
scolebourne at joda.org
Thu Dec 27 06:53:27 PST 2012
On 21 December 2012 20:27, Xueming Shen <xueming.shen at oracle.com> wrote:
> How to define TemporalPeriod is not my point here, the methods I'm
> adding in are to fit it for the minus/plus operation, as the TemporalField/
> Unit interface does. We definitely add more "general" access method
> into it, as you just suggested. Consider this, if we do introduce the
> TemporalPeriod later, does that make the TemporalAdder/Subtractor a
> redundant? at least for all the functionality it currently trying to
> provide?
> then make the TemporalPeriod subclass of both Adder and Subtractor?
Were there to be a TemporalPeriod (since it isn't a temporal, it
should really be called something else, like Perioral), then it would
not extend Adder/Subtractor. However, all *implementations* would
extend TemporalPeriod, Adder and Subtractor.
This is exactly the same as how LocalDate extends both Temporal and
TemporalAdjuster, but Temporal and TemporalAdjuster are independent of
one another. Different layers for different purposes.
> Bottom line is why you need an extra Adder and Subtractor to stand
> in the middle of Temporal = Temporal +/- TemporalDuration, when
> we have a clear defintion of plus/minus, and we have two abstractions
> clearly should/could know how to handle this well-defined operation.
There are other possible classes that might wish to only implement
adder/subtractor, and not be an entire period. The example in the
javadoc is a method returning business/working days
date.plus(workingDays(6));
The concept of "6 working days" is not a period, but it is a mechanism
of addition. That is why Adder is different to the currently
non-existing TemporalPeriod.
Stephen
More information about the threeten-dev
mailing list