StreamEx
发表于|更新于
|浏览量:
这个世界上没有无用的齿轮,也只有齿轮本身能决定自己的用途。——《嫌疑犯X的献身》
跟昨天介绍的eclipse-collections一样,这是一个同类产品:
仓库地址:https://github.com/amaembo/streamex
JavaDoc:http://amaembo.github.io/streamex/javadoc/one/util/streamex/package-summary.html
感受下:
1 | List<String> userNames = StreamEx.of(users).map(User::getName).toList(); |
对比起来好像比eclipse-collections写更少代码

而且更向原生stream靠拢
文档:https://github.com/amaembo/streamex/blob/master/wiki/CHEATSHEET.md
相关推荐
2023-09-01
apache-streamparkpr和代码规范指南
世界上本来就有许多格格不入的事物为了共存而不得不相互接受。——博尔赫斯《沙之书》 最近在为streampark起草代码规范指南,对应的pr如下 https://github.com/apache/incubator-streampark-website/pull/226 对应的内容: 12345678910111213141516<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); yo...
2021-04-26
花式Equals
人们很少做他们相信是对的事,他们做比较方便的事,然后后悔。——鲍勃.迪伦 相信大伙在开发中经常用equals去比较两个对象是否相等,这里分享一下一些别的写法 注意翻转equals:例如我们之前是这样写ruben.equals("ruben"),一定要改成"ruben".equals(ruben) 养成好习惯,利人利己 第一种写法,最常见的这种 12345String ruben = "ruben";String rabbit = "ruben";String achao = "achao";// 常用的Object.equalsSystem.out.println(ruben.equals(rabbit)); 第二种写法,避免空指针 12// 避免空指针的java.util.Objects.equalsSystem.out.println(Objects.equals(ruben, rabbit)); 比较数组的equals 123456// 比较数组的Objects.de...
2021-08-17
fastjson全局序列化坑
偌大的城市,绵延无尽,并非是我眼见的让我停住了脚步,而是我所看不见的。——《海上钢琴师》 今天遇到这样一个问题:序列化出现了与预期不一致的效果,重现代码很简单,就返回一个list,包含几个对象 12345@GetMappingpublic Result testQueryParam(CommonDTO commonDTO) { final UserDetail userDetail = UserDetail.builder().build(); return Result.ok().data(Arrays.asList(userDetail, userDetail, userDetail));} 但可以看到我这里第一条数据是正确的,第二条开始就变成了{$ref: "$.data[0]"} 这是因为我们在使用fastjson作为mvc全局序列化框架的时候 在fastjson中,会自动检测循环引用,并且输出为fastjson专有的引用表示格式。但这个不能被其他JSON库识别,也不能被浏览器识别,所以fastjson提供了关...
2024-09-09
Apache-ShenYu支持namespace功能(四)
教育的最高目标不是知识而是行动。——斯宾塞 本次适配是将几个页面的namespace选择框隐藏了,然后对data-permission数据权限配置弹框里添加了一个namespace选择框,并在内部切换namespace时候刷新表格 PR链接: https://github.com/apache/shenyu-dashboard/pull/479 隐藏namespace的逻辑很简单,首先用withRouter将react组件和dvajs的路由绑定: 1import { withRouter } from "dva/router"; 然后绑定: 1export default withRouter(GlobalHeader); 然后从props里取出当前路由 1const { location: { pathname } } = this.props; 进行判断,当不在下列路由里时,showNamespaces为true 12345678const showNamespaces = !~[ ...
2021-03-05
避免list中remove导致ConcurrentModificationException
凡不是就着泪水吃过面包的人是不懂得人生之味的人——歌德 我们在list循环中调用remove函数删除自身元素可能会导致java.util.ConcurrentModificationException 例如 1234// 构造从0到20的listList<Integer> list = Stream.iterate(0, i -> ++i).limit(20).collect(Collectors.toList());// 删除list.forEach(list::remove); 首先我们可以使用removeIf代替 1list.removeIf(i -> i.equals(i)); 其次我们可以使用迭代器 我们可以看到removeIf的源码正是使用了迭代器 如下 12345Iterator<Integer> iterator = list.iterator();while (iterator.hasNext()) { Integer nowNumber = iterator.next(); iterator....
2023-11-20
docker运行声网linux-server-sdk示例
人类的天性是容易忘记感激别人,所以,如果我们施一点点恩惠都希望别人感激的话,那一定会使我们大为头痛。——戴尔·卡耐基 首先是下载: 下载 - 云信令(原实时消息) - 文档中心 - 声网Agora Agora_RTM_SDK_for_Linux_Java_v1_5_1.zip其中有个samples/Agora-RTM-Tutorial-Java,我们将 libs/libagora_rtm_sdk.so libs/agora_rtm.jar 复制到samples/Agora-RTM-Tutorial-Java/lib下 然后在samples/Agora-RTM-Tutorial-Java下执行命令: 1mvn install:install-file -Dfile=lib/agora_rtm.jar -DgroupId=io.agora.rtm -DartifactId=agora-rtm-sdk -Dversion=1.0 -Dpackaging=jar 然后注意修改代码中的AppId和token 这里我的token采取服务端生成,因此我们还需要这一个jar 12345...
