5
說,我有一個註釋類科特林:科特林 - 如何獲得註釋的屬性值
@Entity @Table(name="user") data class User (val id:Long, val name:String)
我怎樣才能得到name屬性從@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'的','不first' – Ilya
是的,在我心中它是倒退是暫時的,只是簡單的回答不擔心。 –