I'm looking for @NonNull
equivalent Java annotation for primitive data type. I know primitive data cannot be null
, but I wasn't able to find an alternative.
What I'd like to achieve is logically equivalent to:
int mPageNumber;
public void updatePage(@NonNull final Integer nonNull) {
mPageNumber = nonNull.intValue();
}
I tried:
int mPageNumber;
public void updatePage(@NonNull final int nonNull) {
mPageNumber = nonNull;
}
And I get the following lint warning:
Primitive type members cannot be annotated. This inspection reports problems related to @Nullable and @NotNull annotations usage configured in Constant conditions & exceptions inspection.
What can I put in place of @NonNull
and Integer
in updatePage
method above, so that I can have int
as an argument, not Integer
?
You should change the mPageNumber
type to Integer
.
As int
type can not be null
, but Integer
can do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With