5
कहते हैं, मैं एनोटेशन के साथ एक Kotlin वर्ग है:Kotlin - कैसे एनोटेशन विशेषता मान प्राप्त करने के लिए
@Entity @Table(name="user") data class User (val id:Long, val name:String)
मैं @Table टिप्पणी से नाम विशेषता के मान कैसे मिल सकता है?
fun <T> tableName(c: KClass<T>):String {
// i can get the @Table annotation like this:
val t = c.annotations.find { it.annotationClass == Table::class }
// but how can i get the value of "name" attribute from t?
}
'' find' firstOrNull' के बराबर है, नहीं ' – Ilya
हां first', मेरे मन में यह पीछे की ओर अस्थायी रूप से, बस सरलीकृत किया गया, इस सवाल का जवाब यह के बारे में चिंता नहीं। –