BiConsumer的使用
变量指向函数,设置BiConsumer对应的函数入参:
public static BiConsumer<Object, BassErrorInfoInterface> nullThrowError = (obj, bassErrorInfo) -> {
if (obj instanceof List){
if (obj != null && !((List<?>) obj).isEmpty()) return;
}
else if (obj instanceof String){
if (obj != null && !((String) obj).isEmpty()) return;
}
else if (obj instanceof Long){
if (obj != null && ((Long) obj).longValue() != 0) return;
}
else
if (obj != null) return;
throw new BizException(bassErrorInfo);
};
使用该方法的accept:
//方法void accept(T t, U u);通过回调给调用方两个参数T、U,并执行该操作accept
nullThrowError.accept(flowDetailEntityList,ErrorEnums.ACTIVITY_IS_END);