package com.ustadmobile.libcache.db.dao

import androidx.room.RoomDatabase
import androidx.room.util.getColumnIndexOrThrow
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import com.ustadmobile.libcache.db.entities.NewCacheEntry
import javax.`annotation`.processing.Generated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.collections.mutableListOf
import kotlin.reflect.KClass

@Generated(value = ["androidx.room.RoomProcessor"])
@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
public class NewCacheEntryDao_Impl(
  __db: RoomDatabase,
) : NewCacheEntryDao() {
  private val __db: RoomDatabase
  init {
    this.__db = __db
  }

  public override suspend fun findAllNewEntries(): List<NewCacheEntry> {
    val _sql: String = """
        |
        |        SELECT NewCacheEntry.*
        |          FROM NewCacheEntry
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        val _columnIndexOfCacheEntryKey: Int = getColumnIndexOrThrow(_stmt, "cacheEntryKey")
        val _columnIndexOfNceUrl: Int = getColumnIndexOrThrow(_stmt, "nceUrl")
        val _result: MutableList<NewCacheEntry> = mutableListOf()
        while (_stmt.step()) {
          val _item: NewCacheEntry
          val _tmpCacheEntryKey: String
          _tmpCacheEntryKey = _stmt.getText(_columnIndexOfCacheEntryKey)
          val _tmpNceUrl: String
          _tmpNceUrl = _stmt.getText(_columnIndexOfNceUrl)
          _item = NewCacheEntry(_tmpCacheEntryKey,_tmpNceUrl)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun clearAll() {
    val _sql: String = "DELETE FROM NewCacheEntry"
    return performSuspending(__db, false, true) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        _stmt.step()
      } finally {
        _stmt.close()
      }
    }
  }

  public companion object {
    public fun getRequiredConverters(): List<KClass<*>> = emptyList()
  }
}
