Skip to main content

Re: Add five methods in Quantity interface[Proposal]

  • From: Martin Desruisseaux < >
  • To:
  • Subject: Re: Add five methods in Quantity interface[Proposal]
  • Date: Sat, 01 Nov 2014 18:44:43 +0900
  • Organization: Geomatys

Implementing Comparable still necessary if one want to use the Quantity
in an ordered collection like TreeSet, or in Range structure, etc.
Indeed, the LocalTime and LocalDate examples that you gave implement
Comparable, and I presume that their "isBefore" ans "isAfter" methods
are only convenience methods delegating to "compareTo". Note also that
they do not provide methods for all possible combination
("isGreaterThanOrEquals", etc.). For those cases, users can invoke
"compareTo".

I have no objection against Comparable quantities. About methods like
"isGreater", they are convenience methods, not new functionalities. Some
convenience methods are sometime good - but I think we need to be
careful to not put too many of them.

    Martin




Le 01/11/14 18:23, Otávio Gonçalves de Santana a écrit :
> Martin, using the compareto method is really simple to make this.
> About why create this method, is because we are in DSL age, to make
> our code more expressive.
> For example if you look new API how the JSR 310, it is not using
> getInstance how the old API, but .now to create a instance in the
> exact moment.
>
> I believe is more expressive use:
>
> Calendar calendar = Calendar.getInstance();
> LocalTime time = LocalTime.now();
>
> Talking about this JSR, it has comparative method, so the JSR 354 has too.
>
> http://docs.oracle.com/javase/8/docs/api/java/time/LocalTime.html
> http://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html
> http://docs.oracle.com/javase/8/docs/api/java/time/LocalTime.html
>
>
>
> On Sat, Nov 1, 2014 at 12:56 AM, Martin Desruisseaux
> <
> <mailto: >>
>  wrote:
>
>     Le 01/11/14 04:36, Otávio Gonçalves de Santana a écrit :
>>     I would like to propose to add four new comparatives methods in
>>     Quantity interface:
>>
>>       *   boolean isGreaterThan(Quantity<T> quantity);
>>       *   boolean isGreaterThanOrEqualTo(Quantity<T> quantity);
>>       *   boolean isLessThan(Quantity<T> quantity);
>>       *   boolean isLessThanOrEqualTo(Quantity<T> quantity);
>>       *   boolean isEquivalentTo(Quantity<T> quantity);
>>
>     Why not just implement the int compareTo(Quantity<Q>) method that
>     we could inherit from the Comparable interface instead? But I
>     agree with Werner, we need to sort out the Measurement - Quantity
>     relationship first.
>
>         Martin
>



Re: Add five methods in Quantity interface[Proposal]

Otávio Gonçalves de Santana 11/01/2014

<Possible follow-up(s)>

Re: Add five methods in Quantity interface[Proposal]

Martin Desruisseaux 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Otávio Gonçalves de Santana 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Martin Desruisseaux 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Otávio Gonçalves de Santana 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Martin Desruisseaux 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Otávio Gonçalves de Santana 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Werner Keil 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Martin Desruisseaux 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Werner Keil 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Otávio Gonçalves de Santana 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Martin Desruisseaux 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Werner Keil 11/01/2014

Re: Add five methods in Quantity interface[Proposal]

Werner Keil 11/01/2014
 
 
Close
loading
Please Confirm
Close