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