eclipse-collections

简介: eclipse-collections

志向和热爱是伟大行为的双翼。——歌德

之前分享了vavr,今天在分享一个同类框架eclipse-collections

官方文档:http://www.eclipse.org/collections/

<dependency>
  <groupId>org.eclipse.collections</groupId>
  <artifactId>eclipse-collections-api</artifactId>
  <version>11.0.0</version>
</dependency>
<dependency>
  <groupId>org.eclipse.collections</groupId>
  <artifactId>eclipse-collections</artifactId>
  <version>11.0.0</version>
</dependency>

体验下,这是java8 Stream的:

boolean anyPeopleHaveCats =
  this.people
    .stream()
    .anyMatch(person -> person.hasPet(PetType.CAT));
long countPeopleWithCats =
  this.people
    .stream()
    .filter(person -> person.hasPet(PetType.CAT))
    .count();
List<Person> peopleWithCats =
  this.people
    .stream()
    .filter(person -> person.hasPet(PetType.CAT))
    .collect(Collectors.toList());

eclipse-collections

boolean anyPeopleHaveCats =
  this.people
    .anySatisfy(person -> person.hasPet(PetType.CAT));
int countPeopleWithCats =
  this.people
    .count(person -> person.hasPet(PetType.CAT));
MutableList<Person> peopleWithCats =
  this.people
    .select(person -> person.hasPet(PetType.CAT));

简短了原本的代码

目录
打赏
0
0
0
0
29
分享
相关文章
|
3月前
|
Eclipse 创建 Java 项目
Eclipse 创建 Java 项目
67 4
06. 【Java教程】Java 集成开发环境 - Eclipse
06. 【Java教程】Java 集成开发环境 - Eclipse
128 1
eclipse中Java文件生成jar包
eclipse中Java文件生成jar包
105 0
Eclipse代码提示功能设置(Java & Eclipse+CDT C/C++)
  最近在Linux下开发,由于长期使用Visual Studio 2010,对代码提示功能情有独钟,现在在Linux下,使用Eclipse做开发,当然免不了怀念Visual Studio强悍的代码提示,于是在网上搜索了一些文章,整理出关于Eclipse代码提示功能设置的方法。
1871 0
Java8 获取参数名及Idea/Eclipse/Maven配置(转载)
在Java8之前,代码编译为class文件后,方法参数的类型固定,但是方法名称会丢失,方法名称会变成arg0、arg1....。而现在,在Java8开始可以在class文件中保留参数名,这就给反射带来了极大的遍历。像mybatis等需要使用反射机制获取方法参数的时候就可以不用像以前一样需要使用类似于@Para之类的注解。
488 0
Java8 获取参数名及Idea/Eclipse/Maven配置(转载)
eclipse - Java集成开发环境
Eclipse 是一个开放源代码的、基于Java的可扩展开发平台。就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境。幸运的是,Eclipse 附带了一个标准的插件集,包括Java开发工具(Java Development Kit,JDK)。
2017 0

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等