类 StreamExtension
java.lang.Object
org.ssssssss.script.functions.StreamExtension
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明arrayLikeToList(Object arrayLike) 将对象转为Liststatic Objectstatic Object取平均值数组去重数组去重循环Listboolean对List进行过滤intfindNotNull(Object source) static Objectint分组分组将list拼接起来合并两个集合,类似sql join 操作join(Object source, Object target, Function<Object[], Object> condition, Function<Object[], Object> mapping) 合并两个集合,类似 sql join 操作static String将list拼接起来map 函数取最大值取最小值反转将list打乱intboolean排序累计求和
-
构造器详细资料
-
StreamExtension
public StreamExtension()
-
-
方法详细资料
-
arrayLikeToList
@Comment("\u5c06\u5bf9\u8c61\u8f6c\u4e3aList") public static List<Object> arrayLikeToList(Object arrayLike) 将对象转为List -
join
@Comment("\u5c06\u96c6\u5408\u4f7f\u7528\u8fde\u63a5\u7b26\u62fc\u63a5\u8d77\u6765") public static String join(Object target, @Comment(name="separator",value="\u62fc\u63a5\u7b26\uff0c\u5982`,`") String separator) 将list拼接起来 -
asBean
-
asBean
-
push
-
map
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u8f6c\u6362\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object map(Object target, @Comment(name="function",value="\u8f6c\u6362\u51fd\u6570\uff0c\u5982\u63d0\u53d6\u5c5e\u6027`(item)=>item.xxx`") Function<Object[], Object> function) map 函数- 参数:
function- 回调函数
-
filter
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u8fc7\u6ee4\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object filter(Object target, @Comment(name="function",value="\u8fc7\u6ee4\u6761\u4ef6\uff0c\u5982`(item)=>item.xxx == 1`") Function<Object[], Object> function) 对List进行过滤- 参数:
function- 回调函数
-
find
-
findIndex
-
concat
-
toMap
-
toMap
-
each
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u5faa\u73af\u64cd\u4f5c\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object each(Object target, @Comment(name="function",value="\u5faa\u73af\u51fd\u6570\uff0c\u5982\u5faa\u73af\u6dfb\u52a0\u5c5e\u6027`(item)=>{item.xxx = \'newVal\'}`") Function<Object[], Object> function) 循环List- 参数:
function- 回调函数
-
sort
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object sort(Object target, @Comment(name="function",value="\u6392\u5e8f\u51fd\u6570\uff0c\u5982\u4ece\u5927\u5230\u5c0f`(a,b)=>a-b`") Function<Object[], Object> function) 排序 -
reserve
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u53cd\u8f6c\u64cd\u4f5c", origin=true) public Object reserve(Object target) 反转 -
shuffle
@Comment(value="\u5c06\u96c6\u5408\u7684\u987a\u5e8f\u6253\u4e71", origin=true) public Object shuffle(Object target) 将list打乱 -
distinct
数组去重- 从以下版本开始:
- 1.4.6
-
distinct
@Comment(value="\u96c6\u5408\u53bb\u91cd", origin=true) public Object distinct(Object target, @Comment(name="condition",value="\u53bb\u91cd\u8f6c\u6362\u5668\uff0c\u5982\u6839\u636eid\u53bb\u91cd `item=>item.id`") Function<Object[], Object> condition) 数组去重- 从以下版本开始:
- 1.6.2
-
join
@Comment("\u5c06\u96c6\u5408\u4f7f\u7528`,`\u62fc\u63a5\u8d77\u6765") public String join(Object target) 将list拼接起来 -
max
@Comment("\u53d6\u51fa\u96c6\u5408\u6700\u5927\u503c\uff0c\u5982\u679c\u627e\u4e0d\u5230\u8fd4\u56de`null`") public Object max(Object target) 取最大值 -
min
@Comment("\u53d6\u51fa\u96c6\u5408\u6700\u5c0f\u503c\uff0c\u5982\u679c\u627e\u4e0d\u5230\u8fd4\u56de`null`") public Object min(Object target) 取最小值 -
avg
@Comment("\u53d6\u51fa\u96c6\u5408\u5e73\u5747\u503c\uff0c\u5982\u679c\u65e0\u6cd5\u8ba1\u7b97\u8fd4\u56de`null`") public Double avg(Object target) 取平均值 -
sum
累计求和 -
group
@Comment("\u5bf9\u96c6\u5408\u8fdb\u884c\u5206\u7ec4") public Map<Object,List<Object>> group(Object target, @Comment(name="condition",value="\u5206\u7ec4\u6761\u4ef6\uff0c\u5982`item=>item.xxx + \'_\' + item.yyy`") Function<Object[], Object> condition) 分组- 参数:
condition- 分组条件
-
group
@Comment("\u5bf9\u96c6\u5408\u8fdb\u884c\u5206\u7ec4\u5e76\u8f6c\u6362") public Map<Object,Object> group(Object target, @Comment(name="condition",value="\u5206\u7ec4\u6761\u4ef6\uff0c\u5982`item=>item.xxx + \'_\' + item.yyy`") Function<Object[], Object> condition, @Comment(name="mapping",value="\u8f6c\u6362\u51fd\u6570\uff0c\u5982\u5206\u7ec4\u6c42\u548c`(list)=>list.sum()`") Function<Object[], Object> mapping) 分组- 参数:
condition- 分组条件mapping- 结果映射
-
join
@Comment("\u5c06\u4e24\u4e2a\u96c6\u5408\u5173\u8054\u8d77\u6765") public List<Object> join(Object source, @Comment(name="target",value="\u53e6\u4e00\u4e2a\u96c6\u5408") Object target, @Comment(name="condition",value="\u5173\u8054\u6761\u4ef6\uff0c\u5982:`(left,right)=>left.xxx = right.xxx`") Function<Object[], Object> condition) 合并两个集合,类似sql join 操作- 参数:
source- 左表target- 右表condition- 条件
-
join
@Comment("\u5c06\u4e24\u4e2a\u96c6\u5408\u5173\u8054\u5e76\u8f6c\u6362") public List<Object> join(Object source, @Comment(name="target",value="\u53e6\u4e00\u4e2a\u96c6\u5408") Object target, @Comment(name="condition",value="\u5173\u8054\u6761\u4ef6\uff0c\u5982:`(left,right)=>left.xxx == right.xxx`") Function<Object[], Object> condition, @Comment(name="mapping",value="\u6620\u5c04\u51fd\u6570\uff0c\u5982:`(left,right)=>{xxx : left.xxx, yyy : right.yyy}`") Function<Object[], Object> mapping) 合并两个集合,类似 sql join 操作- 参数:
source- 左表target- 右表condition- 条件mapping- 映射
-
skip
-
limit
-
every
-
some
-
findNotNull
-
reduce
@Comment("\u5faa\u73af\u96c6\u5408\u901a\u8fc7\u7ed9\u5b9a\u7684\u8ba1\u7b97\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u65b0\u503c") public Object reduce(Object source, @Comment(name="reduceFunction",value="\u5904\u7406\u51fd\u6570\uff0c\u5982\u7d2f\u52a0\u8ba1\u7b97\uff1a`(val,item)=>val + item`") Function<Object[], Object> reduceFunction) -
first
-
last
-
size
-
getLength
-