6 java annotations intellij-idea
我应该使用以下哪些注释?INTELLIJ引入了带注释的自有库.我读到用这些注释标记方法参数和类attrbiutes很好,但我不知道它们是做什么的.有许多带注释的库(spring也有注释如Nullable).Javax注释由hibernate验证器实现,验证特定类,但INTELLIJ注释仅对方法属性进行重新提醒或警告.让我们说我有Intellij注释课
public class XYZ{
@NotNull
private int id;
@Nullable
private String z;
@NotNull
private String y;
Run Code Online (Sandbox Code Playgroud)
和
public void method(@NotNull String a,String b)
{
...
}
Run Code Online (Sandbox Code Playgroud)
所有注释都在运行时被取消,如果@NotNull参数为null,Intellij会怎么做?它不会抛出任何错误或类似的东西,只会警告我,为什么它对我有用?我认为对于尝试阅读我的代码的人来说可能更有用.
另一个例子,当我在我的用户中有ManyToMany关系时,我应该将其标记为@Nullable吗?当我创建新用户时,它每次都为null,所以它不是必需的,是吗?
我相信你在混合东西: