I have optional object:
Optional<Detail> newestDetail;
I would like to return newestDetail.getId()
or if newestDetail
is null return null
.
Do we have more sophisticated approach of doing this, than following?
return newestDetail.isPresent()?newestDetail.get().getId():null;