I have an enum:
public enum AppEnums {
SERVICE_ERROR,
CONNECTION_ERROR;
}
and I want to use it in an intDef of Android Annotation:
@IntDef({AppEnums.CONNECTION_ERROR, AppEnums.SERVICE_ERROR})
public @interface ServiceErrors {
}
error shows:
incompatible types found, required: 'long'
What I can do with this incompatibility?
I don't want to handle values of AppEnum parameters manually, Enum create values automatically ordinarily. AppEnums.CONNECTION_ERROR.ordinal()
return int value of enum parameter but don't work here.
@IntDef
works only with integer. If you want to work with an Enum you don't need the@IntDef
. Just use the Enum as a parameter. – Avan