I am looking for equivalent Java annotation @NonNullfor a primitive data type. I know that primitive data cannot be null, but I could not find an alternative.
What I would like to achieve is logically equivalent:
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 warning:
Elements of a primitive type cannot be annotated. These inspection reports report problems using @Nullable and @NotNull annotation usage configured in Constant modes and exceptions.
What can I put in place of @NonNulland Integerin the method updatePageabove, so that I can have intas an argument, and not Integer?
source
share