ch.lambdaj.Lambda.sumFrom()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中ch.lambdaj.Lambda.sumFrom()方法的一些代码示例,展示了Lambda.sumFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lambda.sumFrom()方法的具体详情如下:
包路径:ch.lambdaj.Lambda
类名称:Lambda
方法名:sumFrom

Lambda.sumFrom介绍

[英]Returns a lambda function defined as:

sumFrom : (+, iterable) => lambda : (convert : object => number) => number

It is then possibly to curry this function by selecting the convert function that defines of each item must be converted in a number. This is done by invoking on that returned object the method that returns the values of the property to be summed as in the following example

int totalAge = sumFrom(persons).getAge();

The actual class of T is inferred from the class of the first iterable's item, but you can specify a particular class by using the overloaded method.
[中]

代码示例

代码示例来源:origin: mariofusco/lambdaj

  1. /**
  2. * Returns a proxy of the class of the first object in this iterable that when invoked with a method returning a number
  3. * returns the sum of the numbers resulting from the invocation of the same method on each item in this iterable
  4. * @return A proxy of the class of the first object in this iterable representing a sum lambda function
  5. * @throws IllegalArgumentException if this iterable is null or empty
  6. */
  7. public T sumFrom() {
  8. return Lambda.sumFrom(innerIterable);
  9. }

代码示例来源:origin: jtalks-org/jcommune

  1. /**
  2. * Counts the total count of votes in the poll.
  3. *
  4. * @return the total count of votes in the poll
  5. */
  6. public int getTotalVotesCount() {
  7. return sumFrom(pollItems, PollItem.class).getVotesCount();
  8. }

代码示例来源:origin: jtalks-org/jcommune

  1. /**
  2. * Returns a sum of all topic's post count for that branch.
  3. * <p/>
  4. * Value is computed only for the first time (if not set explicitly before),
  5. * so it may not take into account the posts added later
  6. *
  7. * @return sum of post count for all the topics in this branch
  8. */
  9. public int getPostCount() {
  10. if (postsCount == null) {
  11. postsCount = Lambda.sumFrom(topics, Topic.class).getPostCount();
  12. }
  13. return postsCount;
  14. }

相关文章