package world.respect.datalayer.db.school.xapi.daos

import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.util.getColumnIndexOrThrow
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import javax.`annotation`.processing.Generated
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.collections.mutableListOf
import kotlin.reflect.KClass
import world.respect.datalayer.db.school.xapi.entities.XapiVerbLangMapEntry

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

  private val __insertAdapterOfXapiVerbLangMapEntry: EntityInsertAdapter<XapiVerbLangMapEntry>
  init {
    this.__db = __db
    this.__insertAdapterOfXapiVerbLangMapEntry = object : EntityInsertAdapter<XapiVerbLangMapEntry>() {
      protected override fun createQuery(): String = "INSERT OR REPLACE INTO `XapiVerbLangMapEntry` (`vlmeVerbUid`,`vlmeLangCode`,`vlmeEntryString`) VALUES (?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: XapiVerbLangMapEntry) {
        statement.bindLong(1, entity.vlmeVerbUid)
        statement.bindText(2, entity.vlmeLangCode)
        statement.bindText(3, entity.vlmeEntryString)
      }
    }
  }

  public override suspend fun upsertList(list: List<XapiVerbLangMapEntry>): Unit = performSuspending(__db, false, true) { _connection ->
    __insertAdapterOfXapiVerbLangMapEntry.insert(_connection, list)
  }

  public override suspend fun findByVerbUidAsync(verbUid: Long): List<XapiVerbLangMapEntry> {
    val _sql: String = """
        |
        |        SELECT XapiVerbLangMapEntry.*
        |          FROM XapiVerbLangMapEntry
        |         WHERE XapiVerbLangMapEntry.vlmeVerbUid = ?
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, verbUid)
        val _columnIndexOfVlmeVerbUid: Int = getColumnIndexOrThrow(_stmt, "vlmeVerbUid")
        val _columnIndexOfVlmeLangCode: Int = getColumnIndexOrThrow(_stmt, "vlmeLangCode")
        val _columnIndexOfVlmeEntryString: Int = getColumnIndexOrThrow(_stmt, "vlmeEntryString")
        val _result: MutableList<XapiVerbLangMapEntry> = mutableListOf()
        while (_stmt.step()) {
          val _item: XapiVerbLangMapEntry
          val _tmpVlmeVerbUid: Long
          _tmpVlmeVerbUid = _stmt.getLong(_columnIndexOfVlmeVerbUid)
          val _tmpVlmeLangCode: String
          _tmpVlmeLangCode = _stmt.getText(_columnIndexOfVlmeLangCode)
          val _tmpVlmeEntryString: String
          _tmpVlmeEntryString = _stmt.getText(_columnIndexOfVlmeEntryString)
          _item = XapiVerbLangMapEntry(_tmpVlmeVerbUid,_tmpVlmeLangCode,_tmpVlmeEntryString)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun findByVerbUidPair(uid1: Long, uid2: Long): List<XapiVerbLangMapEntry> {
    val _sql: String = """
        |
        |        SELECT XapiVerbLangMapEntry.*
        |          FROM XapiVerbLangMapEntry
        |         WHERE XapiVerbLangMapEntry.vlmeVerbUid = ? 
        |            OR XapiVerbLangMapEntry.vlmeVerbUid = ?
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, uid1)
        _argIndex = 2
        _stmt.bindLong(_argIndex, uid2)
        val _columnIndexOfVlmeVerbUid: Int = getColumnIndexOrThrow(_stmt, "vlmeVerbUid")
        val _columnIndexOfVlmeLangCode: Int = getColumnIndexOrThrow(_stmt, "vlmeLangCode")
        val _columnIndexOfVlmeEntryString: Int = getColumnIndexOrThrow(_stmt, "vlmeEntryString")
        val _result: MutableList<XapiVerbLangMapEntry> = mutableListOf()
        while (_stmt.step()) {
          val _item: XapiVerbLangMapEntry
          val _tmpVlmeVerbUid: Long
          _tmpVlmeVerbUid = _stmt.getLong(_columnIndexOfVlmeVerbUid)
          val _tmpVlmeLangCode: String
          _tmpVlmeLangCode = _stmt.getText(_columnIndexOfVlmeLangCode)
          val _tmpVlmeEntryString: String
          _tmpVlmeEntryString = _stmt.getText(_columnIndexOfVlmeEntryString)
          _item = XapiVerbLangMapEntry(_tmpVlmeVerbUid,_tmpVlmeLangCode,_tmpVlmeEntryString)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

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