java 如何在 IntelliJ 中禁用“可选用作字段或参数类型”警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36166658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:01:23  来源:igfitidea点击:

How to disable the "Optional used as field or parameter type" warning in IntelliJ?

javaintellij-idea

提问by Andrey

Jetbrains has recently decided that java.util.Optional(as well as Guava's com.google.common.base.Optional) shouldn't be used as field or parameter type... thanks, but no thanks... How can this warning be disabled?

Jetbrains 最近决定java.util.Optional(以及 Guava 的com.google.common.base.Optional)不应该用作字段或参数类型......谢谢,但不,谢谢......这个警告怎么可能被禁用?

As a side note: triggering warnings on this specific usage of Optional seems completely unjustified...

附带说明:在 Optional 的这种特定用法上触发警告似乎完全没有道理......

回答by Andrey

From IntelliJ's preferences/settings:

从 IntelliJ 的首选项/设置:

  1. Select Editor> Inspections
  2. Expand Java> Abstraction issues
  3. Uncheck 'Optional' used as field or parameter type
  1. 选择Editor>Inspections
  2. 展开Java>Abstraction issues
  3. 取消选中 'Optional' used as field or parameter type