@Test public void combineTest() { MonetarySummaryStatistics summaryA = createSummary(BRAZILIAN_REAL); MonetarySummaryStatistics summaryB = createSummary(BRAZILIAN_REAL); summaryA.combine(summaryB); Assert.assertEquals(6L, summaryA.getCount()); Assert.assertEquals(10L, summaryA.getMin().getNumber().longValue()); Assert.assertEquals(110L, summaryA.getMax().getNumber().longValue()); Assert.assertEquals(420L, summaryA.getSum().getNumber().longValue()); Assert.assertEquals(70L, summaryA.getAverage().getNumber().longValue()); }
@Override public MonetarySummaryStatistics combine( MonetarySummaryStatistics summaryStatistics) { Objects.requireNonNull(summaryStatistics); if (!equals(summaryStatistics)) { return this; } min = MonetaryFunctions.min(min, summaryStatistics.getMin()); max = MonetaryFunctions.max(max, summaryStatistics.getMax()); sum = sum.add(summaryStatistics.getSum()); count += summaryStatistics.getCount(); average = sum.divide(count); return this; }
DefaultMonetarySummaryStatistics implements MonetarySummaryStatistics { @Override public MonetarySummaryStatistics combine( MonetarySummaryStatistics summaryStatistics) { Objects.requireNonNull(summaryStatistics); if (!equals(summaryStatistics)) { return this; } min = MonetaryFunctions.min(min, summaryStatistics.getMin()); max = MonetaryFunctions.max(max, summaryStatistics.getMax()); sum = sum.add(summaryStatistics.getSum()); count += summaryStatistics.getCount(); average = sum.divide(count); return this; } }
DefaultMonetarySummaryStatistics implements MonetarySummaryStatistics { @Override public MonetarySummaryStatistics combine( MonetarySummaryStatistics summaryStatistics) { Objects.requireNonNull(summaryStatistics); if (!equals(summaryStatistics)) { return this; } min = MonetaryFunctions.min(min, summaryStatistics.getMin()); max = MonetaryFunctions.max(max, summaryStatistics.getMax()); sum = sum.add(summaryStatistics.getSum()); count += summaryStatistics.getCount(); average = sum.divide(count); return this; } protected  DefaultMonetarySummaryStatistics(CurrencyUnit currencyUnit); }
DefaultMonetarySummaryStatistics implements MonetarySummaryStatistics { @Override public MonetarySummaryStatistics combine( MonetarySummaryStatistics summaryStatistics) { Objects.requireNonNull(summaryStatistics); if (!equals(summaryStatistics)) { return this; } min = MonetaryFunctions.min(min, summaryStatistics.getMin()); max = MonetaryFunctions.max(max, summaryStatistics.getMax()); sum = sum.add(summaryStatistics.getSum()); count += summaryStatistics.getCount(); average = sum.divide(count); return this; } protected  DefaultMonetarySummaryStatistics(CurrencyUnit currencyUnit); static DefaultMonetarySummaryStatistics of(CurrencyUnit currencyUnit); @Override void accept(MonetaryAmount amount); @Override CurrencyUnit getCurrencyUnit(); @Override MonetarySummaryStatistics combine(
            MonetarySummaryStatistics summaryStatistics); @Override long getCount(); @Override MonetaryAmount getMin(); @Override MonetaryAmount getMax(); @Override MonetaryAmount getSum(); @Override MonetaryAmount getAverage(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override boolean isExchangeable(); @Override MonetarySummaryStatistics to(CurrencyUnit unit); }
DefaultMonetarySummaryStatistics implements MonetarySummaryStatistics { @Override public MonetarySummaryStatistics combine( MonetarySummaryStatistics summaryStatistics) { Objects.requireNonNull(summaryStatistics); if (!equals(summaryStatistics)) { return this; } min = MonetaryFunctions.min(min, summaryStatistics.getMin()); max = MonetaryFunctions.max(max, summaryStatistics.getMax()); sum = sum.add(summaryStatistics.getSum()); count += summaryStatistics.getCount(); average = sum.divide(count); return this; } protected  DefaultMonetarySummaryStatistics(CurrencyUnit currencyUnit); static DefaultMonetarySummaryStatistics of(CurrencyUnit currencyUnit); @Override void accept(MonetaryAmount amount); @Override CurrencyUnit getCurrencyUnit(); @Override MonetarySummaryStatistics combine(
            MonetarySummaryStatistics summaryStatistics); @Override long getCount(); @Override MonetaryAmount getMin(); @Override MonetaryAmount getMax(); @Override MonetaryAmount getSum(); @Override MonetaryAmount getAverage(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @Override boolean isExchangeable(); @Override MonetarySummaryStatistics to(CurrencyUnit unit);  }