commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksander Ściborek <aleksanderscibo...@gmail.com>
Subject Re: [LANG]DurationUtils pull request reminder
Date Sun, 17 Mar 2019 21:49:22 GMT
I was thinking about this, the implementation of Duration class makes it
quite hard. If method "public long get(TemporalUnit unit)" from Duration
class supported all ChronoUnit it would be pretty easy to do, but with the
current implementation I would have to make a lot of switch or if
statements so therefore I don't see to much benefits from make this in more
objectish way


On Wed, 13 Mar 2019 at 00:20, Eric Barnhill <ericbarnhill@gmail.com> wrote:

> I think this class is on its way howver I agree with Sebb's comments there
> has to be more flexibility about the rounding approach.
>
> I am not sure a Utils class is the way to handle this flexibility. What
> about a DurationRounder class or similar. Then an Enum for rounding method:
> RoundingMethod.ROUND_UP,  RoundingMethod  .ROUND_DOWN etc. You will want to
> include what is known in Matlab as the fix() or "round toward zero" method,
> which is a common method when there are positive and negative numbers.
>
> The user can then set the rounding method of the object during construction
> (or a setter I guess). Then when the object is passed a Duration the state
> of the object will dictate how it rounds. In Python or Matlab the enum
> would reference a function handle, I am not sure what would be the most
> elegant Java solution for such a situation -- perhaps using MethodHandle,
> or using a lambda expression?
>
> And then I would say ditto for the unit of rounding. So rather than
> repetitive methods like roundUpDays(), you construct a
> DurationRounder(RoundingMethod.FIX, RoundingUnit.SECONDS) and then just
> call round() .
>
> Please jump in if anyone finds this approach objectionable.
>
> Eric
>
> On Tue, Mar 12, 2019 at 4:05 PM Aleksander Ściborek <
> aleksandersciborek@gmail.com> wrote:
>
> > Hi,
> > I would like to remind abut my pull request :
> > https://github.com/apache/commons-lang/pull/406
> > I know that you have a lot of work, but please take look at it - this PR
> > was created almost month ago.
> > Aleksander
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message