I am trying to replace some of the enumerations in my source with IntDef annotation. I have been following this documentation.
I have a variable for holding a ViewMode which was previously an enumeration. Now I have changed it to some thing like below.
@Retention(RetentionPolicy.SOURCE)
@IntDef({ViewMode.VIEW_MODE_LIST_VIEW, ViewMode.VIEW_MODE_CARD_VIEW})
public @interface ViewMode {
int VIEW_MODE_LIST_VIEW = 0;
int VIEW_MODE_CARD_VIEW = 1;
}
@ViewMode
public int currentViewMode = ViewMode.VIEW_MODE_LIST_VIEW;
Now to test whether this is safe or not I have done the following in a method
this.currentViewMode = 987; //currentViewMode should be 0 or 1. Nothing else.
But this is now not giving me a compilation error. Am I missing something here?