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         * the currency unit used in summary
062         * @return the currency unit
063         */
064        CurrencyUnit getCurrencyUnit();
065
066        /**
067         * return if is possible do exchange rate or not with the MonetarySummary
068         * @return false;
069         */
070        boolean isExchangeable();
071
072        /**
073         * created the MonetarySummaryStatistics converted to {@link CurrencyUnit}
074         * @param unit
075         *            to be converted
076         * @return MonetarySummaryStatistics converted
077         * @throws UnsupportedOperationException
078         *             if {@link MonetarySummaryStatistics#isExchangeable()} was
079         *             false
080         * @throws NullPointerException
081         *             if unit was null
082         */
083        MonetarySummaryStatistics to(CurrencyUnit unit);
084
085}