比方说,我有一个带注释的Kotlin类:
@Entity @Table(name="user") data class User (val id:Long, val name:String)
Run Code Online (Sandbox Code Playgroud)
如何从@Table注释中获取name属性的值?
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?
}
Run Code Online (Sandbox Code Playgroud)