I am not clear about how we properly use the annotation about nullable i.e. NonNull and Nullable.
I am not really comfortable with something like the following:
public void foo(@NonNull ArrayList<CustomObject> list) {
CustomObject o = list.get(0); //etc
}
1) Is it non-sense to declare non-null and code defensively?
2) What is the most effective way to use such annotations? E.g. as an example
- how should they be used when using the builder pattern or
- when defining an interface for concrete classes to implement? Should the method of implementing classes also contain the annotation or is it assumed?
3) In the snippet above is there a way to define non-null and non-empty?
Aucun commentaire:
Enregistrer un commentaire