Other than the answer for the usage(need) of such a constructor, to be concerned about the correctness of the API implementation, one should really take into consideration of the called out loud API Note such that creation of such instances are under certain thoughtful considerations as(emphasis mine) -
If the count
is zero then the remaining arguments are ignored and an empty instance is constructed.
Example -
var intsummstats = new IntSummaryStatistics();
// creates the following stat
=> IntSummaryStatistics{count=0, sum=0, min=2147483647, average=0.000000, max=-2147483648}
// and the following results into a similar stat as well
var anotherintsummstats = new IntSummaryStatistics(0, 12, 100, 1000);
=> IntSummaryStatistics{count=0, sum=0, min=2147483647, average=0.000000, max=-2147483648}
If the arguments are inconsistent then an IllegalArgumentException
is thrown. The necessary consistent argument conditions are:
But then since this doesn't cover all types of checks over the count
, sum
, max
and min
combination of the values the user can put in, there is this statement(which I found while playing around with the constructor)
The enforcement of argument correctness means that the retrieved set
of recorded values obtained from an *SummaryStatistics
source
instance may not be a legal set of arguments for this constructor due
to arithmetic overflow of the source's recorded count of values. The
consistent argument conditions are not sufficient to prevent the
creation of an internally inconsistent instance. An example of such a
state would be an (IntSummaryStatistics) instance with: count = 2, min = 1, max = 2, and sum
= 0.
and to add to it, such incorrectly created instances when combine
d with other *SummaryStatistic
could result into an illegal set of arguments further.