Does anyone know if the following code that is usi...
# reflect
n
Does anyone know if the following code that is using java reflection can be rewritten to use Kotlin reflection:
Copy code
package com.paxos.eltnam

import com.fasterxml.jackson.annotation.JsonProperty

enum class Fruit(val s: String) {
    @JsonProperty("apples") APPLES("as"),
    @JsonProperty("pears") PEARS("ps")
}

fun main() {
    Fruit::class.java.declaredFields.filter { it.isEnumConstant }
        .map { (it.annotations[0] as JsonProperty).value }
        .forEach { println(it) }
}
no red 1