001package org.javamoney.moneta.function; 002 003import javax.money.CurrencyUnit; 004import javax.money.MonetaryAmount; 005 006/** 007 * A state object for collecting statistics such as count, min, max, sum, and 008 * average. 009 * @author otaviojava 010 * @author Anatole Tresch 011 */ 012public interface MonetarySummaryStatistics { 013 014 /** 015 * Records another value into the summary information. 016 * @param amount 017 * the input amount value to be added, not null. 018 */ 019 void accept(MonetaryAmount amount); 020 021 /** 022 * Combines the state of another {@code MonetarySummaryStatistics} into this 023 * one. 024 * @param summaryStatistics 025 * another {@code MonetarySummaryStatistics}, not null. 026 */ 027 MonetarySummaryStatistics combine( 028 MonetarySummaryStatistics summaryStatistics); 029 030 /** 031 * Get the number of items added to this summary instance. 032 * @return the number of summarized items, >= 0. 033 */ 034 long getCount(); 035 036 /** 037 * Get the minimal amount found within this summary. 038 * @return the minimal amount, or null if no amount was added to this summary instance. 039 */ 040 MonetaryAmount getMin(); 041 042 /** 043 * Get the maximal amount found within this summary. 044 * @return the minimal amount, or null if no amount was added to this summary instance. 045 */ 046 MonetaryAmount getMax(); 047 048 /** 049 * Get the sum of all amounts within this summary. 050 * @return the total amount, or null if no amount was added to this summary instance. 051 */ 052 MonetaryAmount getSum(); 053 054 /** 055 * Get the mean average of all amounts added. 056 * @return the mean average amount, or null if no amount was added to this summary instance. 057 */ 058 MonetaryAmount getAverage(); 059 060 /** 061 * will equals when the currencies were equals 062 */ 063 @Override 064 boolean equals(Object obj); 065 066 /** 067 * the currency unit used in summary 068 * @return the currency unit 069 */ 070 CurrencyUnit getCurrencyUnit(); 071 072 /** 073 * return if is possible do exchange rate or not with the MonetarySummary 074 * @return false; 075 */ 076 boolean isExchangeable(); 077 078 /** 079 * created the MonetarySummaryStatistics converted to {@link CurrencyUnit} 080 * @param unit 081 * to be converted 082 * @return MonetarySummaryStatistics converted 083 * @throws UnsupportedOperationException 084 * if {@link MonetarySummaryStatistics#isExchangeable()} was 085 * false 086 * @throws NullPointerException 087 * if unit was null 088 */ 089 MonetarySummaryStatistics to(CurrencyUnit unit); 090 091}