com.penglecode.codeforce.common.util.StreamUtils Maven / Gradle / Ivy
The newest version!
package com.penglecode.codeforce.common.util;
import java.util.function.BinaryOperator;
/**
* Java8 Stream工具类
*
* @author pengpeng
* @version 1.0
*/
public class StreamUtils {
private StreamUtils() {}
/**
* 针对Collectors.toMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction)方法的第三个参数mergeFunction的工具类,
* 该preferNewMergeFunction()方法返回的Lambda表达式返回倾向于新的那个value值
*
* @param
* @return
*/
public static BinaryOperator preferNew() {
return (oldValue, newValue) -> newValue;
}
/**
* 针对Collectors.toMap(Function keyMapper, Function valueMapper, BinaryOperator mergeFunction)方法的第三个参数mergeFunction的工具类,
* 该preferOldMergeFunction()方法返回的Lambda表达式返回倾向于旧的那个value值
*
* @param
* @return
*/
public static BinaryOperator preferOld() {
return (oldValue, newValue) -> newValue;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy