in commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/LongStatistics.java [572:623]
public StatisticResult getResult(Statistic statistic) {
// Locate the implementation.
// Statistics that wrap an underlying implementation are created in methods.
// The return argument should be an interface reference and not an instance
// of LongStatistic. This ensures the statistic implementation cannot
// be updated with new values by casting the result and calling accept(long).
StatisticResult stat = null;
switch (statistic) {
case GEOMETRIC_MEAN:
stat = getGeometricMean();
break;
case KURTOSIS:
stat = getKurtosis();
break;
case MAX:
stat = Statistics.getResultAsLongOrNull(max);
break;
case MEAN:
stat = getMean();
break;
case MIN:
stat = Statistics.getResultAsLongOrNull(min);
break;
case PRODUCT:
stat = Statistics.getResultAsDoubleOrNull(product);
break;
case SKEWNESS:
stat = getSkewness();
break;
case STANDARD_DEVIATION:
stat = getStandardDeviation();
break;
case SUM:
stat = Statistics.getResultAsBigIntegerOrNull(sum);
break;
case SUM_OF_LOGS:
stat = Statistics.getResultAsDoubleOrNull(sumOfLogs);
break;
case SUM_OF_SQUARES:
stat = Statistics.getResultAsBigIntegerOrNull(sumOfSquares);
break;
case VARIANCE:
stat = getVariance();
break;
default:
break;
}
if (stat != null) {
return stat;
}
throw new IllegalArgumentException(UNSUPPORTED_STATISTIC + statistic);
}