Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 1 | import android.database.Cursor |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 2 | import androidx.room.EntityInsertionAdapter |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 3 | import androidx.room.RoomDatabase |
| 4 | import androidx.room.RoomSQLiteQuery |
| 5 | import androidx.room.RoomSQLiteQuery.Companion.acquire |
| 6 | import androidx.room.util.getColumnIndexOrThrow |
| 7 | import androidx.room.util.query |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 8 | import androidx.sqlite.db.SupportSQLiteStatement |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 9 | import java.lang.Class |
| 10 | import java.lang.IllegalArgumentException |
| 11 | import javax.`annotation`.processing.Generated |
| 12 | import kotlin.Int |
| 13 | import kotlin.String |
| 14 | import kotlin.Suppress |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 15 | import kotlin.Unit |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 16 | import kotlin.collections.List |
| 17 | import kotlin.jvm.JvmStatic |
| 18 | |
| 19 | @Generated(value = ["androidx.room.RoomProcessor"]) |
elifbilgin | d46e8c1 | 2023-01-17 09:32:11 -0800 | [diff] [blame] | 20 | @Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION"]) |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 21 | public class MyDao_Impl( |
| 22 | __db: RoomDatabase, |
| 23 | ) : MyDao { |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 24 | private val __db: RoomDatabase |
| 25 | |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 26 | private val __insertionAdapterOfMyEntity: EntityInsertionAdapter<MyEntity> |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 27 | init { |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 28 | this.__db = __db |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 29 | this.__insertionAdapterOfMyEntity = object : EntityInsertionAdapter<MyEntity>(__db) { |
| 30 | public override fun createQuery(): String = |
| 31 | "INSERT OR ABORT INTO `MyEntity` (`pk`,`enum`,`nullableEnum`) VALUES (?,?,?)" |
| 32 | |
| 33 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity): Unit { |
| 34 | statement.bindLong(1, entity.pk.toLong()) |
| 35 | statement.bindString(2, __Fruit_enumToString(entity.enum)) |
Daniel Santiago Rivera | bb3ff86 | 2023-03-24 10:55:09 -0400 | [diff] [blame^] | 36 | val _tmpNullableEnum: Fruit? = entity.nullableEnum |
| 37 | if (_tmpNullableEnum == null) { |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 38 | statement.bindNull(3) |
| 39 | } else { |
Daniel Santiago Rivera | bb3ff86 | 2023-03-24 10:55:09 -0400 | [diff] [blame^] | 40 | statement.bindString(3, __Fruit_enumToString(_tmpNullableEnum)) |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | public override fun addEntity(item: MyEntity): Unit { |
| 47 | __db.assertNotSuspendingTransaction() |
| 48 | __db.beginTransaction() |
| 49 | try { |
| 50 | __insertionAdapterOfMyEntity.insert(item) |
| 51 | __db.setTransactionSuccessful() |
| 52 | } finally { |
| 53 | __db.endTransaction() |
| 54 | } |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | public override fun getEntity(): MyEntity { |
| 58 | val _sql: String = "SELECT * FROM MyEntity" |
| 59 | val _statement: RoomSQLiteQuery = acquire(_sql, 0) |
| 60 | __db.assertNotSuspendingTransaction() |
| 61 | val _cursor: Cursor = query(__db, _statement, false, null) |
| 62 | try { |
| 63 | val _cursorIndexOfPk: Int = getColumnIndexOrThrow(_cursor, "pk") |
| 64 | val _cursorIndexOfEnum: Int = getColumnIndexOrThrow(_cursor, "enum") |
| 65 | val _cursorIndexOfNullableEnum: Int = getColumnIndexOrThrow(_cursor, "nullableEnum") |
| 66 | val _result: MyEntity |
| 67 | if (_cursor.moveToFirst()) { |
| 68 | val _tmpPk: Int |
| 69 | _tmpPk = _cursor.getInt(_cursorIndexOfPk) |
| 70 | val _tmpEnum: Fruit |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 71 | _tmpEnum = __Fruit_stringToEnum(_cursor.getString(_cursorIndexOfEnum)) |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 72 | val _tmpNullableEnum: Fruit? |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 73 | if (_cursor.isNull(_cursorIndexOfNullableEnum)) { |
| 74 | _tmpNullableEnum = null |
| 75 | } else { |
| 76 | _tmpNullableEnum = __Fruit_stringToEnum(_cursor.getString(_cursorIndexOfNullableEnum)) |
| 77 | } |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 78 | _result = MyEntity(_tmpPk,_tmpEnum,_tmpNullableEnum) |
| 79 | } else { |
| 80 | error("Cursor was empty, but expected a single item.") |
| 81 | } |
| 82 | return _result |
| 83 | } finally { |
| 84 | _cursor.close() |
| 85 | _statement.release() |
| 86 | } |
| 87 | } |
| 88 | |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 89 | private fun __Fruit_enumToString(_value: Fruit): String = when (_value) { |
| 90 | Fruit.APPLE -> "APPLE" |
| 91 | Fruit.BANANA -> "BANANA" |
| 92 | } |
| 93 | |
| 94 | private fun __Fruit_stringToEnum(_value: String): Fruit = when (_value) { |
| 95 | "APPLE" -> Fruit.APPLE |
| 96 | "BANANA" -> Fruit.BANANA |
| 97 | else -> throw IllegalArgumentException("Can't convert value to enum, unknown value: " + _value) |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | public companion object { |
| 101 | @JvmStatic |
| 102 | public fun getRequiredConverters(): List<Class<*>> = emptyList() |
| 103 | } |
| 104 | } |