commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] Commented: (MATH-261) Add generics to Frequency
Date Wed, 15 Apr 2009 14:05:15 GMT


Sebb commented on MATH-261:

I'm not trying to argue, just understand.

The code currently does:

Object obj = v;
if (v instanceof Integer) {
  obj = Long.valueOf(((Integer) v).longValue());

I.e. when v is an Integer, then obj is not the same as v, so put((T) obj,...) cannot be replaced
by put(v,..)


Regarding the generics change. It looks like there is no support for changing the API to require
Comparable rather than Object. 
This is a pity, as it would improve compile-time safety. if only the original design had used
Comparable instead of Object...

I'll see if it is possible to change the patch accordingly, whilst still retaining some of
the generics to improve compile-time checking.

> Add generics to Frequency
> -------------------------
>                 Key: MATH-261
>                 URL:
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Sebb
>             Fix For: 2.0
>         Attachments: Frequency.patch
> I've attempted to add generics to Frequency.
> This requires a minor change to the API, in that Objects to be used with the class need
to be Comparable.
> This will break some code, e.g. one change was needed to the test cases.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message