I develop Android applications and often use annotations as compile time parameter checks, mostly android's support annotations.
Example in java code:
public class Test
{
@IntDef({Speed.SLOW,Speed.NORMAL,Speed.FAST})
public @interface Speed
{
public static final int SLOW = 0;
public static final int NORMAL = 1;
public static final int FAST = 2;
}
@Speed
private int speed;
public void setSpeed(@Speed int speed)
{
this.speed = speed;
}
}
I don't want to use enums because of their performance issues in Android. The automatic converter to kotlin just generates invalid code. How do I use the @IntDef
annotation in kotlin?