Skip to content

Commit

Permalink
Make MapInfoDao accept collection instead of vararg
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPushkin committed Aug 20, 2022
1 parent 163287b commit 36ed3ce
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -66,7 +66,7 @@ class AppDatabaseDaosTest {
MapInfo("abc", 100, 100, 1024, 1, 5),
MapInfo("cba", 100, 200, 512, 2, 100)
)
runBlocking { mapInfoDao.insertAll(*expected.toTypedArray()) }
runBlocking { mapInfoDao.insertAll(expected) }

val actual = runBlocking {
listOf(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ru/spbu/depnav/data/db/MapInfoDao.kt
Expand Up @@ -28,7 +28,7 @@ import ru.spbu.depnav.data.model.MapInfo
interface MapInfoDao {
/** Inserts the provided [MapInfo] entries into the database. */
@Insert
suspend fun insertAll(vararg mapInfos: MapInfo)
suspend fun insertAll(mapInfos: Collection<MapInfo>)

/** Returns a [MapInfo] with the provided map name. */
@Query("SELECT * FROM map_infos WHERE map_name = :name")
Expand Down
Expand Up @@ -25,7 +25,7 @@ import javax.inject.Inject
/** Repository for loading and saving [MapInfo] objects. */
class MapInfoRepo @Inject constructor(private val dao: MapInfoDao) {
/** Saves the provided objects. */
suspend fun insertAll(vararg mapInfos: MapInfo) = dao.insertAll(*mapInfos)
suspend fun insertAll(mapInfos: Collection<MapInfo>) = dao.insertAll(mapInfos)

/** Loads a [MapInfo] by its name. */
suspend fun loadByName(name: String) = dao.loadByName(name)
Expand Down

0 comments on commit 36ed3ce

Please sign in to comment.