示例:
public class MyClass {
private @NotNull String value;
public void setValue(@NotNull String value) {
this.value = value;
}
public @NotNull String getValue() {
return value;
}
}
这样的字段可能违反非 null 约束。 在上例中,setValue
参数批注为非 null,但是如果没有调用 setter,getValue
可能返回 null。
配置检查:
setUp()
方法中写入该字段时是否应发出警告。