I'm trying to define an IntDef
interface in Kotlin but then use those constants in Java. I am able to access it, but I get an IDE Lint error when I try to do a equals operator on it. Though, a different comparison operator (<, >) works fine. Even using 'Objects.equal()' works, just not ==. Anyone have any idea about this?
Error: Must be one of: 1L, 2L
My Kotlin Class
class RandomClass{
...
@IntDef(STATE_1, STATE_2)
@Retention(AnnotationRetention.SOURCE)
annotation class MyState
companion object {
const val STATE_1 = 1L
const val STATE_2 = 2L
}
Accessing the Annotation in Java where Error Occurs
void myFunction(@RandomClass.MyState long state){
if(state == RandomClass.STATE_1){
...
}
}
My Temp Fix for this
void myFunction(@RandomClass.MyState long state){
if(Objects.equal(state, RandomClass.STATE_1)){
...
}
}