Kotlin中的Room Junction语法

时间:2019-07-13 04:44:05

标签: android kotlin android-room

在下面的示例中,FolderItem::class属于value的{​​{1}}属性,即使未明确说明:

Junction

它的编译和运行与我写出来的相同:

class FolderWithItems( @Embedded val folder: Folder, @Relation( associateBy = Junction( FolderItem::class, parentColumn = "folder_id", entityColumn = "item_id" ), parentColumn = "id", entityColumn = "id" ) val items: List<Item> )

什么是Kotlin原则/规则/语言功能,使您在这种情况下不必指定value = FolderItem::class