一种抑制方法参数的方法是使用 javadoc 标记:
/**
* @noinspection CollectionDeclaredAsConcreteClass
*/
public PropertiesExpander(Properties properties) {
this.properties.putAll(properties);
}
这个 javadoc 标签是非常特定于 IntelliJ 的,所以其他工具都不应该有任何问题。您可以通过直接识别它或添加一些注释来轻松识别它:
/**
* @noinspection IntelliJ CollectionDeclaredAsConcreteClass
*/
public PropertiesExpander(Properties properties) {
this.properties.putAll(properties);
}
当然,您可以进一步缩短它:
/** @noinspection CollectionDeclaredAsConcreteClass */
public PropertiesExpander(Properties properties) {
this.properties.putAll(properties);
}
一般的做法
可以使用特殊注释而不是注释逐个抑制某些警告@SuppressWarnings
。
这是一个带有很多警告的示例:

如果按Alt+ Enter,notUsedLocalVariable
则可以Suppress for statement with comment
在上下文菜单上进行选择(在选择 时向右后Remove variable ...
)。
在某些变量/字段/方法上,选定的抑制只是Suppress for statement
.
现在,如果您查看右侧字段,则大多数(不是全部)警告已被抑制:

如您所见,同一注释行上可能有多个抑制。
这似乎有点乏味,但我认为这是你能做的最好的。