package com.changhong.epc.count.service.tool;
|
|
import com.changhong.epc.bean.count.MasterInfo;
|
import com.changhong.epc.bean.tenant.master.MasterEleValue;
|
import com.iemsoft.framework.cloud.core.tools.StringUtil;
|
|
import java.util.Objects;
|
import java.util.Set;
|
import java.util.function.Function;
|
import java.util.function.Supplier;
|
|
public class MasterListTool {
|
|
/**
|
* 优先添加,不为空的和后来的
|
* @param arrays
|
* @param functionEmpty
|
* @param args
|
* @param <T>
|
*/
|
public static <T> void add(Boolean replace, Set<T> arrays, Function<T, Boolean> functionEmpty, T... args){
|
if(args == null || args.length == 0){
|
return;
|
}
|
// 忽略 出发站点、出发地
|
|
|
for(T arg : args){
|
if(functionEmpty.apply(arg)) {
|
continue;
|
}
|
if(replace) {
|
if (arrays.contains(arg)) {
|
arrays.remove(arg);
|
}
|
arrays.add(arg);
|
}else{
|
arrays.add(arg);
|
}
|
}
|
}
|
|
|
@FunctionalInterface
|
public interface FunctionEmpty<T>{
|
|
boolean isEmpty(T arg);
|
|
}
|
|
public static boolean valIsEmpty(MasterInfo masterInfo){
|
return StringUtil.isBlank(Objects.toString(masterInfo.getMeVal()));
|
}
|
|
public static boolean valIsEmpty(MasterEleValue masterEleValue){
|
return StringUtil.isBlank(masterEleValue.getMvCode());
|
}
|
}
|