if(Optional.isPresent())
示例:
if (str.isPresent()) str.get().trim();
在应用快速修复后:
str.ifPresent(String::trim);
仅当项目或模块的语言级别为 8 或更高时才报告此检查。