public class StreamExtension extends Object
| 构造器和说明 |
|---|
StreamExtension() |
| 限定符和类型 | 方法和说明 |
|---|---|
static List<Object> |
arrayLikeToList(Object arrayLike)
将对象转为List
|
static Object |
asBean(Object source,
Class<?> target) |
static Object |
asBean(Object source,
Class<?> target,
boolean isArray) |
Double |
avg(Object target)
取平均值
|
Object |
each(Object target,
Function<Object[],Object> function)
循环List
|
boolean |
every(Object source,
Function<Object[],Object> condition) |
Object |
filter(Object target,
Function<Object[],Object> function)
对List进行过滤
|
Object |
findNotNull(Object source) |
Map<Object,List<Object>> |
group(Object target,
Function<Object[],Object> condition)
分组
|
Map<Object,Object> |
group(Object target,
Function<Object[],Object> condition,
Function<Object[],Object> mapping)
分组
|
String |
join(Object target)
将list拼接起来
|
List<Object> |
join(Object source,
Object target,
Function<Object[],Object> condition)
合并两个集合,类似sql join 操作
|
List<Object> |
join(Object source,
Object target,
Function<Object[],Object> condition,
Function<Object[],Object> mapping)
合并两个集合,类似 sql join 操作
|
static String |
join(Object target,
String separator)
将list拼接起来
|
Object |
limit(Object source,
int value) |
Object |
map(Object target,
Function<Object[],Object> function)
map 函数
|
Object |
max(Object target)
取最大值
|
Object |
min(Object target)
取最小值
|
Object |
push(Object target,
Object item) |
Object |
reduce(Object source,
Function<Object[],Object> reduceFunction) |
Object |
reserve(Object target)
反转
|
Object |
shuffle(Object target)
将list打乱
|
Object |
skip(Object source,
int value) |
boolean |
some(Object source,
Function<Object[],Object> condition) |
Object |
sort(Object target,
Function<Object[],Object> function)
排序
|
Number |
sum(Object target)
累计求和
|
@Comment(value="\u5c06\u5bf9\u8c61\u8f6c\u4e3aList") public static List<Object> arrayLikeToList(Object arrayLike)
@Comment(value="\u5411\u96c6\u5408\u4e2d\u6dfb\u52a0\u5143\u7d20", origin=true) public Object push(Object target, @Comment(value="\u8981\u6dfb\u52a0\u7684\u5143\u7d20") Object item)
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u8f6c\u6362\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object map(Object target, @Comment(value="\u8f6c\u6362\u51fd\u6570\uff0c\u5982\u63d0\u53d6\u5c5e\u6027(item)=>item.xxx") Function<Object[],Object> function)
function - 回调函数@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u8fc7\u6ee4\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object filter(Object target, @Comment(value="\u8fc7\u6ee4\u6761\u4ef6\uff0c\u5982(item)=>item.xxx == 1") Function<Object[],Object> function)
function - 回调函数@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(value="\u5faa\u73af\u51fd\u6570\uff0c\u5982\u5faa\u73af\u6dfb\u52a0\u5c5e\u6027(item)=>{item.xxx = \'newVal\'}") Function<Object[],Object> function)
function - 回调函数@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u8fd4\u56de\u65b0\u96c6\u5408", origin=true) public Object sort(Object target, @Comment(value="\u6392\u5e8f\u51fd\u6570\uff0c\u5982\u4ece\u5927\u5230\u5c0f(a,b)=>a-b") Function<Object[],Object> function)
@Comment(value="\u5c06\u96c6\u5408\u8fdb\u884c\u53cd\u8f6c\u64cd\u4f5c", origin=true) public Object reserve(Object target)
@Comment(value="\u5c06\u96c6\u5408\u7684\u987a\u5e8f\u6253\u4e71", origin=true) public Object shuffle(Object target)
@Comment(value="\u5c06\u96c6\u5408\u4f7f\u7528`,`\u62fc\u63a5\u8d77\u6765") public String join(Object target)
@Comment(value="\u5c06\u96c6\u5408\u4f7f\u7528\u8fde\u63a5\u7b26\u62fc\u63a5\u8d77\u6765") public static String join(Object target, @Comment(value="\u62fc\u63a5\u7b26\uff0c\u5982`,`") String separator)
@Comment(value="\u53d6\u51fa\u96c6\u5408\u6700\u5927\u503c\uff0c\u5982\u679c\u627e\u4e0d\u5230\u8fd4\u56denull") public Object max(Object target)
@Comment(value="\u53d6\u51fa\u96c6\u5408\u6700\u5c0f\u503c\uff0c\u5982\u679c\u627e\u4e0d\u5230\u8fd4\u56denull") public Object min(Object target)
@Comment(value="\u53d6\u51fa\u96c6\u5408\u5e73\u5747\u503c\uff0c\u5982\u679c\u65e0\u6cd5\u8ba1\u7b97\u8fd4\u56denull") public Double avg(Object target)
@Comment(value="\u5bf9\u96c6\u5408\u8fdb\u884c\u7d2f\u52a0\u64cd\u4f5c") public Number sum(Object target)
@Comment(value="\u5bf9\u96c6\u5408\u8fdb\u884c\u5206\u7ec4") public Map<Object,List<Object>> group(Object target, @Comment(value="\u5206\u7ec4\u6761\u4ef6\uff0c\u5982item=>item.xxx + \'_\' + item.yyy") Function<Object[],Object> condition)
condition - 分组条件@Comment(value="\u5bf9\u96c6\u5408\u8fdb\u884c\u5206\u7ec4\u5e76\u8f6c\u6362") public Map<Object,Object> group(Object target, @Comment(value="\u5206\u7ec4\u6761\u4ef6\uff0c\u5982item=>item.xxx + \'_\' + item.yyy") Function<Object[],Object> condition, @Comment(value="\u8f6c\u6362\u51fd\u6570\uff0c\u5982\u5206\u7ec4\u6c42\u548c(list)=>list.sum()") Function<Object[],Object> mapping)
condition - 分组条件mapping - 结果映射@Comment(value="\u5c06\u4e24\u4e2a\u96c6\u5408\u5173\u8054\u8d77\u6765") public List<Object> join(Object source, @Comment(value="\u53e6\u4e00\u4e2a\u96c6\u5408") Object target, @Comment(value="\u5173\u8054\u6761\u4ef6\uff0c\u5982:(left,right)=>left.xxx = right.xxx") Function<Object[],Object> condition)
source - 左表target - 右表condition - 条件@Comment(value="\u5c06\u4e24\u4e2a\u96c6\u5408\u5173\u8054\u5e76\u8f6c\u6362") public List<Object> join(Object source, @Comment(value="\u53e6\u4e00\u4e2a\u96c6\u5408") Object target, @Comment(value="\u5173\u8054\u6761\u4ef6\uff0c\u5982:(left,right)=>left.xxx == right.xxx") Function<Object[],Object> condition, @Comment(value="\u6620\u5c04\u51fd\u6570\uff0c\u5982:(left,right)=>{xxx : left.xxx, yyy : right.yyy}") Function<Object[],Object> mapping)
source - 左表target - 右表condition - 条件mapping - 映射@Comment(value="\u5c06\u96c6\u5408\u8f6c\u4e3aJavaBean") public static Object asBean(Object source, @Comment(value="\u76ee\u6807\u7c7b\u578b") Class<?> target)
@Comment(value="\u622a\u53d6\u96c6\u5408", origin=true) public Object skip(Object source, @Comment(value="\u8df3\u8fc7\u7684\u6570\u91cf") int value)
@Comment(value="\u9650\u5236\u96c6\u5408\u6570\u91cf", origin=true) public Object limit(Object source, @Comment(value="\u8df3\u8fc7\u7684\u6570\u91cf") int value)
@Comment(value="\u5224\u65ad\u96c6\u5408\u662f\u5426\u90fd\u6ee1\u8db3\u6761\u4ef6") public boolean every(Object source, @Comment(value="\u5224\u65ad\u6761\u4ef6") Function<Object[],Object> condition)
@Comment(value="\u5224\u65ad\u96c6\u5408\u4e2d\u662f\u5426\u81f3\u5c11\u6709\u4e00\u4e2a\u5143\u7d20\u6ee1\u8db3\u6761\u4ef6") public boolean some(Object source, @Comment(value="\u5224\u65ad\u6761\u4ef6") Function<Object[],Object> condition)
@Comment(value="\u627e\u5230\u96c6\u5408\u4e2d\u7b2c\u4e00\u4e2a\u4e0d\u4e3anull\u7684\u5143\u7d20") public Object findNotNull(Object source)
@Comment(value="\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(value="\u5904\u7406\u51fd\u6570\uff0c\u5982\u7d2f\u52a0\u8ba1\u7b97\uff1a(val,item)=>val + item") Function<Object[],Object> reduceFunction)
Copyright © 2020–2021. All rights reserved.