Spec and API review for {Int,Long,Double}SummaryStatistics

Mike Duigou mike.duigou at oracle.com
Thu Mar 28 18:37:03 PDT 2013

I've responded to the survey feedback and updated the implementations with additional Javadoc.

One comment which was not addressed was whether getAverage() should throw a zero division ArithmeticException if no values had been recorded. I believe the current default of returning 0.0 is reasonable and it is convenient to not have to check the catch the exception. It's also in line with the defaults we provide for sum, sumOfSquares, min, and max. For any of these defaults users can check the count themselves and choose to substitute their own default. double average = summary.getCount() != 0 ? summary.getAverage() : Double.NAN;

I did introduce an ArithmeticException to IntSummaryStatistics.getSum() if the sum cannot be expressed as an int. Remember that the sum  is internally maintained in a long and there is a long accessor, getAsLong().

On Mar 22 2013, at 15:00 , Brian Goetz wrote:

> I've posted a survey at:
>  https://www.surveymonkey.com/s/5VTLT26
> To do an API and spec review for the classes Int/Long/DoubleSummaryStatistics.  If you have comments, please provide them in the SurveyMonkey form.  Usual password.

More information about the lambda-libs-spec-experts mailing list