多层if如何优化
请教各位大佬 ,像这种多层的if该如何优化一下呢 用运算符& 稍等一下,我把粘贴到编辑器分析一下 lambda 表达式? List<CustomerFinanceDTO> customerFinanceList = proFinanceInfo;if (ObjectUtil.isNotEmpty(customerFinanceList) && customerFinanceList.size() > ACCOUNT_SIZE_ZERO) {
for (CustomerFinanceDTO item : customerFinanceList) {
if (reportId.equals(item.getCustomerFinanceId())) {
boolean sendFlag = CreditUtils.checkValInCommonClass(
new CreditModelCdsSecond.ProjectCdClass1(),
requestDTO.getGradeModeLNo()
);
if (sendFlag) {
projectValue01 = item.getProjectValue();
}
}
}
}
试试 chatgpt优化的。有没有用? 据说解决这个问题得研究一下传说中的设计模式了 sfl4800 发表于 2023-2-22 13:47
List customerFinanceList = proFinanceInfo;
if (ObjectUtil.isNotEmpty(customerFinanceList) && custom ...
听起来是个好主意 Broadm 发表于 2023-2-22 13:43
lambda 表达式?
我去看看
for(){
if(!(~~~~~)){continue;}
~~~~~~~
}
sfl4800 发表于 2023-2-22 13:47
List customerFinanceList = proFinanceInfo;
if (ObjectUtil.isNotEmpty(customerFinanceList) && custom ...
不能说一模一样吧,if一个没少,代码反而从8行加到了14行,这玩意优化代码片段好像不太行啊