Adam Heath wrote:
Adrian Crum wrote:
Adam Heath wrote:
The javadoc for org.ofbiz.base.util.TimeDuration says it is immutable;
however, it's fields are not final, and lots of methods modify it's
fields.
The methods that modify fields are directly or indirectly called by the
constructor and are protected. Let me know if any public method modifies
a field.
fromLong modifies the fields directly, not from the constructor.
fromLong is a static method that returns an immutable instance.
makeNegative modifies the fields.
makeNegative is protected and used internally.
set() is protected, TimeDuration is not final, so sub-classes could
change the fields.
If I need to extend TimeDuration, then I might also need to change the
fields.
Ideally, this class should extend Number, or some other number class.
Why?
It should also normalize it's values. If I set a duration of 86400
seconds, it should normalize to 1 day.
Agreed. That was something I always wanted to add, but never got around
to it.
Also, the 7 arg constructor incorrectly sets itself negative. If I
set a duration of 5 days, and -30 seconds, it'll think it's negative.
If normalization code was written, then that scenario could be
accommodated. For now a duration is positive or negative.