本文整理汇总了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);
}
示例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);
}