Reputation:
Which of these annotations should i use? INTELLIJ introduced own library with annotations. I read that it is good practive to mark methods parameters and class attrbiutes with these annotations but i wonder what they do. There are many libraries with annotations(spring also have annotations like Nullable). Javax annotations are implemented by hibernate validator which validates particular classes but INTELLIJ annotations only remid or warn about method's attribute. Lets say that i have class with Intellij annotations
public class XYZ{
@NotNull
private int id;
@Nullable
private String z;
@NotNull
private String y;
} and
public void method(@NotNull String a,String b)
{
...
}
All annotations are chekced during runtime, what would do Intellij if @NotNull parameter will be null? It doesnt throw any error or somethind like that, only warn me, why it can be useful for me ? I think that it might be more useful for someone who will try read my code.
The other example when i have ManyToMany relation in my user then should i mark it as @Nullable ? It will be every time null when i created new user so it isnt necessary, is it?
Upvotes: 9
Views: 5960
Reputation: 1658
i believe you are mixing things:
Upvotes: 9