I am using Spring Data Mongo Pageable and Sonar giving me below error:
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);
Error:
Call "Optional#isPresent()" before accessing the value.
I tried few options but nothing is working out.