我正在使用 Spring Data Mongo Pageable和Sonar给我以下错误:
Optional<Order> optional = pageable.getSort().stream().findFirst();
if(optional.isPresent()) {
direction = pageable.getSort().stream().findFirst().get().getDirection();
property = pageable.getSort().stream().findFirst().get().getProperty();
}
SortOperation sortOperation = Aggregation.sort(direction, property);
错误:
在访问值之前调用“Optional#isPresent()”。
我尝试了几个选项,但没有任何效果。