I want to update an entry as following:
public Entry updateEmail(String nom, EntryRequest entryReq) {
Optional<Entry> optional = entryRepository.findByNom(nom);
Entry updatedEntry = null;
optional.ifPresent(entry -> {
if(!StringUtils.isEmpty(entryReq.getEmail())){
entry.setEmail(entryReq.getEmail());
}
updatedEntry = save(entry);
});
optional.orElseThrow(() -> new NotFoundException(this.getClass().getName()));
return updatedEntry;
}
This code gives me the following error message :
Variable used in lambda expression should be final or effectively final
How can I solve this ?