當前位置: 首頁>>代碼示例>>Java>>正文


Java GroupMonetarySummaryStatistics類代碼示例

本文整理匯總了Java中org.javamoney.moneta.function.GroupMonetarySummaryStatistics的典型用法代碼示例。如果您正苦於以下問題:Java GroupMonetarySummaryStatistics類的具體用法?Java GroupMonetarySummaryStatistics怎麽用?Java GroupMonetarySummaryStatistics使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GroupMonetarySummaryStatistics類屬於org.javamoney.moneta.function包,在下文中一共展示了GroupMonetarySummaryStatistics類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.javamoney.moneta.function.GroupMonetarySummaryStatistics; //導入依賴的package包/類
public static void main(String[] args) {
    CurrencyUnit dollar = Monetary.getCurrency("USD");
    CurrencyUnit real = Monetary.getCurrency("BRL");



    MonetaryAmount money = Money.of(10, dollar);
    MonetaryAmount money2 = Money.of(10, real);
    MonetaryAmount money3 = Money.of(10, dollar);
    MonetaryAmount money4 = Money.of(9, real);
    MonetaryAmount money5 = Money.of(25, dollar);

    GroupMonetarySummaryStatistics grouped = Stream.of(money, money2, money3, money4, money5)
    .collect(MonetaryFunctions.groupBySummarizingMonetary());
    Map<CurrencyUnit, MonetarySummaryStatistics> mapSummary = grouped.get();
    MonetarySummaryStatistics summary = mapSummary.get(dollar);

    MonetaryAmount min = summary.getMin();//USD 10
    MonetaryAmount max = summary.getMax();//USD 25
    MonetaryAmount average = summary.getAverage();//USD 15
    long count = summary.getCount();//3
    MonetaryAmount sum = summary.getSum();//USD 45

}
 
開發者ID:otaviojava,項目名稱:money-api-book-samples,代碼行數:25,代碼來源:AggregateGroupSummaringMonetaryAmount.java

示例2: main

import org.javamoney.moneta.function.GroupMonetarySummaryStatistics; //導入依賴的package包/類
public static void main(String[] args) {
	Map<CurrencyUnit, List<MonetaryAmount>> groupBy = getCurrencies()
			.stream().collect(MonetaryFunctions.groupByCurrencyUnit());
	MonetarySummaryStatistics summary = getCurrencies().stream()
			.filter(MonetaryFunctions.isCurrency(DOLLAR))
			.collect(MonetaryFunctions.summarizingMonetary(DOLLAR));
	GroupMonetarySummaryStatistics groupSummary = getCurrencies().stream()
			.filter(MonetaryFunctions.isCurrency(DOLLAR))
			.collect(MonetaryFunctions.groupBySummarizingMonetary());

	System.out.println(groupBy);
	System.out.println(summary.getMin());
	System.out.println(summary.getMax());
	System.out.println(summary.getAverage());
	System.out.println(summary.getCount());
	System.out.println(groupSummary);
}
 
開發者ID:JavaMoney,項目名稱:javamoney-examples,代碼行數:18,代碼來源:MonetaryGroupOperations.java

示例3: groupBySummarizingMonetaryTest

import org.javamoney.moneta.function.GroupMonetarySummaryStatistics; //導入依賴的package包/類
@Test
public void groupBySummarizingMonetaryTest() {
    GroupMonetarySummaryStatistics group = currenciesToSummary().collect(
            groupBySummarizingMonetary());
    Map<CurrencyUnit, MonetarySummaryStatistics> mapSummary = group.get();
    assertEquals(mapSummary.keySet().size(), 3);
}
 
開發者ID:JavaMoney,項目名稱:jsr354-ri,代碼行數:8,代碼來源:ConversionAggregatorTest.java


注:本文中的org.javamoney.moneta.function.GroupMonetarySummaryStatistics類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。