189 8069 5689

【java8stream工具】-创新互联

java8 stream 工具
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.collections4.CollectionUtils;

网站建设哪家好,找创新互联建站!专注于网页设计、网站建设、微信开发、小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了昂昂溪免费建站欢迎大家使用!

public class StreamUtil {
private StreamUtil() {
throw new IllegalArgumentException(“Utility class”);
}

public static void consumerList(List list, Consumer consumer) {
if (!CollectionUtils.isEmpty(list)) {
list.stream().forEach(consumer);
}
}

public staticListmapList(Listlist, Functionfunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyList() : (List)list.stream().map(function).collect(Collectors.toList());
}

public staticListfilterList(Listlist, Predicatepredicate) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyList() : (List)list.stream().filter(predicate).collect(Collectors.toList());
}

public staticListmultiFilterList(Listlist, Predicate... predicates) {
    if (CollectionUtils.isEmpty(list)) {
        return Collections.emptyList();
    } else {
        Streamstream = list.stream();
        Predicate[] var3 = predicates;
        int var4 = predicates.length;

        for(int var5 = 0; var5< var4; ++var5) {
            Predicatepredicate = var3[var5];
            stream = stream.filter(predicate);
        }

        return (List)stream.collect(Collectors.toList());
    }
}

public staticMaplistToMap(Listlist, Functionfunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyMap() : (Map)list.stream().collect(Collectors.toMap(function, Function.identity()));
}

public staticListfilterAndMapList(Listlist, Predicatepredicate, Functionfunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyList() : (List)list.stream().filter(predicate).map(function).collect(Collectors.toList());
}

public staticMapfilter2Map(Setlist, Predicatepredicate, FunctionkeyFunction, FunctionvalueFunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyMap() : (Map)list.stream().filter(predicate).collect(Collectors.toMap(keyFunction, valueFunction));
}

public staticMapmapCollect2Map(Listlist, FunctionmapFunction, FunctionkeyFunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyMap() : (Map)list.stream().map(mapFunction).collect(Collectors.toMap(keyFunction, Function.identity()));
}

public staticMapcollect2Map(Listlist, FunctionkeyFunction, FunctionvalueFunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyMap() : (Map)list.stream().collect(Collectors.toMap(keyFunction, valueFunction));
}

public staticMap>list2GroupMap(Listlist, FunctionkeyFunction) {
    return CollectionUtils.isEmpty(list) ? Collections.emptyMap() : (Map)list.stream().collect(Collectors.groupingBy(keyFunction));
}

public staticListlistDistinct(Listlist) {
    return (List)list.stream().distinct().collect(Collectors.toList());
}

public staticListlist2MapAndDistinct(Listlist, Functionfunction) {
    return (List)list.stream().map(function).distinct().collect(Collectors.toList());
}

}

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


网页题目:【java8stream工具】-创新互联
标题URL:http://jkwzsj.com/article/diocdd.html

其他资讯