lawlorslaw
02/06/2020, 9:14 AMinterface RoomModel
and an entity that implements this interface
@Entity(tableName = "ContentAuthorModule")
ContentAuthorModule : RoomModel {}
now if i have a
List<RoomModel>
how do i check if its a
List<ContentAuthorModule>
I tried to do
roomModels is List<ContentAuthorModule>
override fun saveRoomModels(roomModels: List<RoomModel>) {
when(roomModels) {
is List<ContentAuthorModule> ->
contentAuthorModuleDao.insertAll(roomModels)
}
}
but it gives my a syntax error that says
Cannot check for instance of erased type : List<ContentAuthorModule>
is there another way to do this?Ahmed Ibrahim
02/06/2020, 9:31 AMroomModels.filterIsInstance<ContentAuthorModule>()
which will return a list of type List<ContentAuthorModule>
is
because List is a generic, so during runtime the types are erased.