对于具有多个参数的方法,例如此构造函数:
public Chron ( UUID id , UUID trackId , Instant whenCreated , Instant whenLastModified , Instant start , Instant stop , String summary , String notes )
…有没有办法用 @NotNull
标记所有这些参数在 IntelliJ 2019.2 中编辑源代码时添加注释?重复粘贴看起来很愚蠢。
最佳答案
你试过吗@ParametersAreNonnullByDefault
如上所述 here .
使用示例位于 package package-info.java
文件中的级别。
@ParametersAreNonnullByDefault
package com.example.acme.backend.data;
import javax.annotation.ParametersAreNonnullByDefault;
要使用此注释,请添加 jsr305
库,它是 Google Code FindBugs 的一部分。项目。查看另一个问题,What is the status of JSR 305? 。
<!-- https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305 -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
关于java - 为IntelliJ中的所有参数添加@NotNull注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57799511/