提交 fac7262d 作者: zgz

空指针异常处理

上级 4a8560d5
...@@ -259,7 +259,10 @@ public class InformationServiceImpl implements InformationService { ...@@ -259,7 +259,10 @@ public class InformationServiceImpl implements InformationService {
List<Label> listLabel = info.getLabels(); List<Label> listLabel = info.getLabels();
// 使用流操作找到score最大的Label // 使用流操作找到score最大的Label
Optional<Label> maxLabel = listLabel.stream() Optional<Label> maxLabel = listLabel.stream()
.filter(label -> searchCondition.getLabelMark().equals(label.getLabelMark())) // 过滤labelMark .filter(label -> label != null
&& searchCondition != null
&& searchCondition.getLabelMark() != null
&& searchCondition.getLabelMark().equals(label.getLabelMark())) // 过滤labelMark
.peek(label -> label.setStatus(label.getStatus() == null ? 0 : label.getStatus())) // 将null赋值为0 .peek(label -> label.setStatus(label.getStatus() == null ? 0 : label.getStatus())) // 将null赋值为0
.max(Comparator.comparingDouble(Label::getStatus)); .max(Comparator.comparingDouble(Label::getStatus));
List<Label> maxLabelList = maxLabel.map(Collections::singletonList).orElse(Collections.emptyList()); List<Label> maxLabelList = maxLabel.map(Collections::singletonList).orElse(Collections.emptyList());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论