List<ActivationDTO> digitalOtputs = activationsDto.stream()
.filter(x -> x.getOutputDevice().getAddress() == DeviceOutputAddress.SOL_01.getValue()
&& x.getReaderActivation().getActionEventType().equals(val))
.collect(Collectors.toList());
int time = 0;
try {
time = digitalOtputs.get(0).getReaderActivation().getActivationTime();
} catch (Exception e) {
logger.error(String.format("Error at time config %1$s", reader.getId()) + ". " + e);
}
答案 0 :(得分:-1)
mabe结果为空,首先检查是否为null然后使用方法
if(digitalOtputs.get(0) != null && digitalOtputs.get(0).getReaderActivation() != null) {
digitalOtputs.get(0).getReaderActivation().getActivationTime();
}