Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special annotations in RxJava

When I use rxjava Android Studio automatically uses

@io.reactivex.annotations.NonNull

as annotation for methods.

Is there any issue if I replace it with the

@android.support.annotation.NonNull

instead?

I'm a bit afraid that I would lose some lint checks but I did not find anything about it

like image 505
1048576 Avatar asked Mar 09 '23 19:03

1048576


1 Answers

There is no issue with replacing this annotation as it is just an hint for static analysis.
In fact, by default Android Studio would not recognize RxJava2 @io.reactivex.annotations.NonNull as non null annotation and thus will not assert lint warnings. so if you keep using android default non null (@android.support.annotation.NonNull) you will be covered by lint.
That also means that all RxJava2 library methods will not be considered with lint, unless you will change Android Studio settings.

To sum it up, it doesn't really matter what non null annotation you're using as long as you add it to lint warnings (o.w. you miss the point with this annotations).

to add RxJava2 annotation to Android Studio inspection, go to Inspection -> Constant conditions & Exception -> configure annotations, in Nullable/NotNull configuration add RxJava NonNull annotation:

enter image description here

like image 185
yosriz Avatar answered Mar 25 '23 05:03

yosriz