当前位置: 首页>>代码示例>>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;未经允许,请勿转载。