Anotação Kotlin IntDef
Eu tenho este exemplo de código:
class MeasureTextView: TextView {
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
companion object{
val UNIT_NONE = -1
val UNIT_KG = 1
val UNIT_LB = 0
}
fun setMeasureText(number: Float, unitType: Int){
val suffix = when(unitType){
UNIT_NONE -> {
EMPTY_STRING
}
UNIT_KG -> {
KG_SUFIX
}
UNIT_LB -> {
LB_SUFIX
}
else -> throw IllegalArgumentException("Wrong unitType passed to formatter: MeasureTextView.setMeasureText")
}
// set the final text
text = "$number $suffix"
}
}
Quero poder usar, em tempo de compilação, o recurso de preenchimento automático em conjunto com a anotação IntDef, portanto, quando invocosetMeasureText(...)
, as variáveis estáticas são mostradas como opções para o argumento deste método.
Eu pesquisei sobre isso e não consegui descobrir se o Kotlin suportava essas anotações no estilo java (intdef por exemplo). Então, eu tentei e fiz uma anotação para isso, mas não será exibida no preenchimento automático.
Minha pergunta: - A anotação Java IntDef é suportada no Kotlin (versão mais recente)
Se for, como ativar o Android Studio IDE (se funcionar, não consigo sugerir o compilador).
Caso contrário, existe alguma maneira de o Kotlin fazer essa verificação do tempo de compilação