elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 1 | import android.database.Cursor |
| 2 | import android.os.CancellationSignal |
| 3 | import androidx.room.EntityDeletionOrUpdateAdapter |
| 4 | import androidx.room.EntityInsertionAdapter |
| 5 | import androidx.room.EntityUpsertionAdapter |
| 6 | import androidx.room.RoomDatabase |
| 7 | import androidx.room.RoomSQLiteQuery |
| 8 | import androidx.room.RoomSQLiteQuery.Companion.acquire |
| 9 | import androidx.room.guava.GuavaRoom |
| 10 | import androidx.room.util.appendPlaceholders |
| 11 | import androidx.room.util.createCancellationSignal |
| 12 | import androidx.room.util.getColumnIndexOrThrow |
| 13 | import androidx.room.util.newStringBuilder |
| 14 | import androidx.room.util.query |
| 15 | import androidx.sqlite.db.SupportSQLiteStatement |
| 16 | import com.google.common.util.concurrent.ListenableFuture |
| 17 | import java.lang.Class |
| 18 | import java.lang.StringBuilder |
| 19 | import java.util.concurrent.Callable |
| 20 | import javax.`annotation`.processing.Generated |
| 21 | import kotlin.Int |
| 22 | import kotlin.Long |
| 23 | import kotlin.String |
| 24 | import kotlin.Suppress |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 25 | import kotlin.collections.List |
| 26 | import kotlin.jvm.JvmStatic |
| 27 | |
| 28 | @Generated(value = ["androidx.room.RoomProcessor"]) |
elifbilgin | d46e8c1 | 2023-01-17 09:32:11 -0800 | [diff] [blame] | 29 | @Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION"]) |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 30 | public class MyDao_Impl( |
| 31 | __db: RoomDatabase, |
| 32 | ) : MyDao { |
| 33 | private val __db: RoomDatabase |
| 34 | |
| 35 | private val __insertionAdapterOfMyEntity: EntityInsertionAdapter<MyEntity> |
| 36 | |
| 37 | private val __deletionAdapterOfMyEntity: EntityDeletionOrUpdateAdapter<MyEntity> |
| 38 | |
| 39 | private val __updateAdapterOfMyEntity: EntityDeletionOrUpdateAdapter<MyEntity> |
| 40 | |
| 41 | private val __upsertionAdapterOfMyEntity: EntityUpsertionAdapter<MyEntity> |
| 42 | init { |
| 43 | this.__db = __db |
| 44 | this.__insertionAdapterOfMyEntity = object : EntityInsertionAdapter<MyEntity>(__db) { |
| 45 | public override fun createQuery(): String = |
| 46 | "INSERT OR ABORT INTO `MyEntity` (`pk`,`other`) VALUES (?,?)" |
| 47 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 48 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 49 | statement.bindLong(1, entity.pk.toLong()) |
| 50 | statement.bindString(2, entity.other) |
| 51 | } |
| 52 | } |
| 53 | this.__deletionAdapterOfMyEntity = object : EntityDeletionOrUpdateAdapter<MyEntity>(__db) { |
| 54 | public override fun createQuery(): String = "DELETE FROM `MyEntity` WHERE `pk` = ?" |
| 55 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 56 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 57 | statement.bindLong(1, entity.pk.toLong()) |
| 58 | } |
| 59 | } |
| 60 | this.__updateAdapterOfMyEntity = object : EntityDeletionOrUpdateAdapter<MyEntity>(__db) { |
| 61 | public override fun createQuery(): String = |
| 62 | "UPDATE OR ABORT `MyEntity` SET `pk` = ?,`other` = ? WHERE `pk` = ?" |
| 63 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 64 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 65 | statement.bindLong(1, entity.pk.toLong()) |
| 66 | statement.bindString(2, entity.other) |
| 67 | statement.bindLong(3, entity.pk.toLong()) |
| 68 | } |
| 69 | } |
| 70 | this.__upsertionAdapterOfMyEntity = EntityUpsertionAdapter<MyEntity>(object : |
| 71 | EntityInsertionAdapter<MyEntity>(__db) { |
| 72 | public override fun createQuery(): String = |
| 73 | "INSERT INTO `MyEntity` (`pk`,`other`) VALUES (?,?)" |
| 74 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 75 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 76 | statement.bindLong(1, entity.pk.toLong()) |
| 77 | statement.bindString(2, entity.other) |
| 78 | } |
| 79 | }, object : EntityDeletionOrUpdateAdapter<MyEntity>(__db) { |
| 80 | public override fun createQuery(): String = |
| 81 | "UPDATE `MyEntity` SET `pk` = ?,`other` = ? WHERE `pk` = ?" |
| 82 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 83 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 84 | statement.bindLong(1, entity.pk.toLong()) |
| 85 | statement.bindString(2, entity.other) |
| 86 | statement.bindLong(3, entity.pk.toLong()) |
| 87 | } |
| 88 | }) |
| 89 | } |
| 90 | |
| 91 | public override fun insertListenableFuture(vararg entities: MyEntity): |
| 92 | ListenableFuture<List<Long>> = GuavaRoom.createListenableFuture(__db, true, object : |
| 93 | Callable<List<Long>> { |
| 94 | public override fun call(): List<Long> { |
| 95 | __db.beginTransaction() |
| 96 | try { |
| 97 | val _result: List<Long> = __insertionAdapterOfMyEntity.insertAndReturnIdsList(entities) |
| 98 | __db.setTransactionSuccessful() |
| 99 | return _result |
| 100 | } finally { |
| 101 | __db.endTransaction() |
| 102 | } |
| 103 | } |
| 104 | }) |
| 105 | |
| 106 | public override fun deleteListenableFuture(entity: MyEntity): ListenableFuture<Int> = |
| 107 | GuavaRoom.createListenableFuture(__db, true, object : Callable<Int> { |
| 108 | public override fun call(): Int { |
| 109 | var _total: Int = 0 |
| 110 | __db.beginTransaction() |
| 111 | try { |
| 112 | _total += __deletionAdapterOfMyEntity.handle(entity) |
| 113 | __db.setTransactionSuccessful() |
| 114 | return _total |
| 115 | } finally { |
| 116 | __db.endTransaction() |
| 117 | } |
| 118 | } |
| 119 | }) |
| 120 | |
| 121 | public override fun updateListenableFuture(entity: MyEntity): ListenableFuture<Int> = |
| 122 | GuavaRoom.createListenableFuture(__db, true, object : Callable<Int> { |
| 123 | public override fun call(): Int { |
| 124 | var _total: Int = 0 |
| 125 | __db.beginTransaction() |
| 126 | try { |
| 127 | _total += __updateAdapterOfMyEntity.handle(entity) |
| 128 | __db.setTransactionSuccessful() |
| 129 | return _total |
| 130 | } finally { |
| 131 | __db.endTransaction() |
| 132 | } |
| 133 | } |
| 134 | }) |
| 135 | |
| 136 | public override fun upsertListenableFuture(vararg entities: MyEntity): |
| 137 | ListenableFuture<List<Long>> = GuavaRoom.createListenableFuture(__db, true, object : |
| 138 | Callable<List<Long>> { |
| 139 | public override fun call(): List<Long> { |
| 140 | __db.beginTransaction() |
| 141 | try { |
| 142 | val _result: List<Long> = __upsertionAdapterOfMyEntity.upsertAndReturnIdsList(entities) |
| 143 | __db.setTransactionSuccessful() |
| 144 | return _result |
| 145 | } finally { |
| 146 | __db.endTransaction() |
| 147 | } |
| 148 | } |
| 149 | }) |
| 150 | |
| 151 | public override fun getListenableFuture(vararg arg: String?): ListenableFuture<MyEntity> { |
| 152 | val _stringBuilder: StringBuilder = newStringBuilder() |
| 153 | _stringBuilder.append("SELECT * FROM MyEntity WHERE pk IN (") |
| 154 | val _inputSize: Int = arg.size |
| 155 | appendPlaceholders(_stringBuilder, _inputSize) |
| 156 | _stringBuilder.append(")") |
| 157 | val _sql: String = _stringBuilder.toString() |
| 158 | val _argCount: Int = 0 + _inputSize |
| 159 | val _statement: RoomSQLiteQuery = acquire(_sql, _argCount) |
| 160 | var _argIndex: Int = 1 |
| 161 | for (_item: String? in arg) { |
| 162 | if (_item == null) { |
| 163 | _statement.bindNull(_argIndex) |
| 164 | } else { |
| 165 | _statement.bindString(_argIndex, _item) |
| 166 | } |
| 167 | _argIndex++ |
| 168 | } |
| 169 | val _cancellationSignal: CancellationSignal? = createCancellationSignal() |
| 170 | return GuavaRoom.createListenableFuture(__db, false, object : Callable<MyEntity> { |
| 171 | public override fun call(): MyEntity { |
| 172 | val _cursor: Cursor = query(__db, _statement, false, _cancellationSignal) |
| 173 | try { |
| 174 | val _cursorIndexOfPk: Int = getColumnIndexOrThrow(_cursor, "pk") |
| 175 | val _cursorIndexOfOther: Int = getColumnIndexOrThrow(_cursor, "other") |
| 176 | val _result: MyEntity |
| 177 | if (_cursor.moveToFirst()) { |
| 178 | val _tmpPk: Int |
| 179 | _tmpPk = _cursor.getInt(_cursorIndexOfPk) |
| 180 | val _tmpOther: String |
| 181 | _tmpOther = _cursor.getString(_cursorIndexOfOther) |
| 182 | _result = MyEntity(_tmpPk,_tmpOther) |
| 183 | } else { |
elifbilgin | 22935ce | 2023-07-25 14:14:10 -0700 | [diff] [blame^] | 184 | error("The query result was empty, but expected a single row to return a NON-NULL object of type <MyEntity>.") |
elifbilgin | 1f76654 | 2022-11-21 17:21:44 -0800 | [diff] [blame] | 185 | } |
| 186 | return _result |
| 187 | } finally { |
| 188 | _cursor.close() |
| 189 | } |
| 190 | } |
| 191 | }, _statement, true, _cancellationSignal) |
| 192 | } |
| 193 | |
| 194 | public override fun getListenableFutureNullable(vararg arg: String?): |
| 195 | ListenableFuture<MyEntity?> { |
| 196 | val _stringBuilder: StringBuilder = newStringBuilder() |
| 197 | _stringBuilder.append("SELECT * FROM MyEntity WHERE pk IN (") |
| 198 | val _inputSize: Int = arg.size |
| 199 | appendPlaceholders(_stringBuilder, _inputSize) |
| 200 | _stringBuilder.append(")") |
| 201 | val _sql: String = _stringBuilder.toString() |
| 202 | val _argCount: Int = 0 + _inputSize |
| 203 | val _statement: RoomSQLiteQuery = acquire(_sql, _argCount) |
| 204 | var _argIndex: Int = 1 |
| 205 | for (_item: String? in arg) { |
| 206 | if (_item == null) { |
| 207 | _statement.bindNull(_argIndex) |
| 208 | } else { |
| 209 | _statement.bindString(_argIndex, _item) |
| 210 | } |
| 211 | _argIndex++ |
| 212 | } |
| 213 | val _cancellationSignal: CancellationSignal? = createCancellationSignal() |
| 214 | return GuavaRoom.createListenableFuture(__db, false, object : Callable<MyEntity?> { |
| 215 | public override fun call(): MyEntity? { |
| 216 | val _cursor: Cursor = query(__db, _statement, false, _cancellationSignal) |
| 217 | try { |
| 218 | val _cursorIndexOfPk: Int = getColumnIndexOrThrow(_cursor, "pk") |
| 219 | val _cursorIndexOfOther: Int = getColumnIndexOrThrow(_cursor, "other") |
| 220 | val _result: MyEntity? |
| 221 | if (_cursor.moveToFirst()) { |
| 222 | val _tmpPk: Int |
| 223 | _tmpPk = _cursor.getInt(_cursorIndexOfPk) |
| 224 | val _tmpOther: String |
| 225 | _tmpOther = _cursor.getString(_cursorIndexOfOther) |
| 226 | _result = MyEntity(_tmpPk,_tmpOther) |
| 227 | } else { |
| 228 | _result = null |
| 229 | } |
| 230 | return _result |
| 231 | } finally { |
| 232 | _cursor.close() |
| 233 | } |
| 234 | } |
| 235 | }, _statement, true, _cancellationSignal) |
| 236 | } |
| 237 | |
| 238 | public companion object { |
| 239 | @JvmStatic |
| 240 | public fun getRequiredConverters(): List<Class<*>> = emptyList() |
| 241 | } |
| 242 | } |