package i.b.a;

import android.database.CrossProcessCursor;
import android.database.Cursor;
import android.database.CursorWindow;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: compiled from: AbstractDao.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class a<T, K> {
    protected final i.b.a.k.a config;
    protected final i.b.a.i.a db;
    protected i.b.a.j.a<K, T> identityScope;
    protected i.b.a.j.b<T> identityScopeLong;
    protected final boolean isStandardSQLite;
    protected final int pkOrdinal;
    protected final c session;
    protected i.b.a.k.e statements;

    public a(i.b.a.k.a aVar) {
        this(aVar, null);
    }

    /* JADX WARN: Multi-variable type inference failed */
    private void deleteByKeyInsideSynchronized(K k2, i.b.a.i.c cVar) {
        if (k2 instanceof Long) {
            cVar.c(1, ((Long) k2).longValue());
        } else {
            if (k2 == 0) {
                throw new d("Cannot delete entity, key is null");
            }
            cVar.b(1, k2.toString());
        }
        cVar.execute();
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0040 A[Catch: all -> 0x003c, TryCatch #2 {all -> 0x003c, blocks: (B:10:0x0021, B:11:0x0025, B:13:0x002b, B:15:0x0038, B:19:0x0040, B:20:0x0044, B:22:0x004a, B:24:0x0053), top: B:49:0x0021, outer: #0 }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0065 A[Catch: all -> 0x0081, Merged into TryCatch #1 {all -> 0x0084, blocks: (B:3:0x000e, B:34:0x006b, B:36:0x0072, B:38:0x0076, B:43:0x0083, B:4:0x000f, B:6:0x0013, B:30:0x0061, B:32:0x0065, B:33:0x006a, B:26:0x0057, B:28:0x005b, B:29:0x0060, B:10:0x0021, B:11:0x0025, B:13:0x002b, B:15:0x0038, B:19:0x0040, B:20:0x0044, B:22:0x004a, B:24:0x0053), top: B:48:0x000e }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private void deleteInTxInternal(java.lang.Iterable<T> r4, java.lang.Iterable<K> r5) {
        /*
            r3 = this;
            r3.assertSinglePk()
            i.b.a.k.e r0 = r3.statements
            i.b.a.i.c r0 = r0.b()
            i.b.a.i.a r1 = r3.db
            r1.c()
            monitor-enter(r0)     // Catch: java.lang.Throwable -> L84
            i.b.a.j.a<K, T> r1 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            if (r1 == 0) goto L1e
            i.b.a.j.a<K, T> r1 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            r1.lock()     // Catch: java.lang.Throwable -> L81
            java.util.ArrayList r1 = new java.util.ArrayList     // Catch: java.lang.Throwable -> L81
            r1.<init>()     // Catch: java.lang.Throwable -> L81
            goto L1f
        L1e:
            r1 = 0
        L1f:
            if (r4 == 0) goto L3e
            java.util.Iterator r4 = r4.iterator()     // Catch: java.lang.Throwable -> L3c
        L25:
            boolean r2 = r4.hasNext()     // Catch: java.lang.Throwable -> L3c
            if (r2 == 0) goto L3e
            java.lang.Object r2 = r4.next()     // Catch: java.lang.Throwable -> L3c
            java.lang.Object r2 = r3.getKeyVerified(r2)     // Catch: java.lang.Throwable -> L3c
            r3.deleteByKeyInsideSynchronized(r2, r0)     // Catch: java.lang.Throwable -> L3c
            if (r1 == 0) goto L25
            r1.add(r2)     // Catch: java.lang.Throwable -> L3c
            goto L25
        L3c:
            r4 = move-exception
            goto L57
        L3e:
            if (r5 == 0) goto L61
            java.util.Iterator r4 = r5.iterator()     // Catch: java.lang.Throwable -> L3c
        L44:
            boolean r5 = r4.hasNext()     // Catch: java.lang.Throwable -> L3c
            if (r5 == 0) goto L61
            java.lang.Object r5 = r4.next()     // Catch: java.lang.Throwable -> L3c
            r3.deleteByKeyInsideSynchronized(r5, r0)     // Catch: java.lang.Throwable -> L3c
            if (r1 == 0) goto L44
            r1.add(r5)     // Catch: java.lang.Throwable -> L3c
            goto L44
        L57:
            i.b.a.j.a<K, T> r5 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            if (r5 == 0) goto L60
            i.b.a.j.a<K, T> r5 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            r5.unlock()     // Catch: java.lang.Throwable -> L81
        L60:
            throw r4     // Catch: java.lang.Throwable -> L81
        L61:
            i.b.a.j.a<K, T> r4 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            if (r4 == 0) goto L6a
            i.b.a.j.a<K, T> r4 = r3.identityScope     // Catch: java.lang.Throwable -> L81
            r4.unlock()     // Catch: java.lang.Throwable -> L81
        L6a:
            monitor-exit(r0)     // Catch: java.lang.Throwable -> L81
            i.b.a.i.a r4 = r3.db     // Catch: java.lang.Throwable -> L84
            r4.g()     // Catch: java.lang.Throwable -> L84
            if (r1 == 0) goto L7b
            i.b.a.j.a<K, T> r4 = r3.identityScope     // Catch: java.lang.Throwable -> L84
            if (r4 == 0) goto L7b
            i.b.a.j.a<K, T> r4 = r3.identityScope     // Catch: java.lang.Throwable -> L84
            r4.c(r1)     // Catch: java.lang.Throwable -> L84
        L7b:
            i.b.a.i.a r4 = r3.db
            r4.b()
            return
        L81:
            r4 = move-exception
            monitor-exit(r0)     // Catch: java.lang.Throwable -> L81
            throw r4     // Catch: java.lang.Throwable -> L84
        L84:
            r4 = move-exception
            i.b.a.i.a r5 = r3.db
            r5.b()
            throw r4
        */
        throw new UnsupportedOperationException("Method not decompiled: i.b.a.a.deleteInTxInternal(java.lang.Iterable, java.lang.Iterable):void");
    }

    private long executeInsert(T t, i.b.a.i.c cVar, boolean z) {
        long jInsertInsideTx;
        if (this.db.a()) {
            jInsertInsideTx = insertInsideTx(t, cVar);
        } else {
            this.db.c();
            try {
                jInsertInsideTx = insertInsideTx(t, cVar);
                this.db.g();
            } finally {
                this.db.b();
            }
        }
        if (z) {
            updateKeyAfterInsertAndAttach(t, jInsertInsideTx, true);
        }
        return jInsertInsideTx;
    }

    private void executeInsertInTx(i.b.a.i.c cVar, Iterable<T> iterable, boolean z) {
        this.db.c();
        try {
            synchronized (cVar) {
                if (this.identityScope != null) {
                    this.identityScope.lock();
                }
                try {
                    if (this.isStandardSQLite) {
                        SQLiteStatement sQLiteStatement = (SQLiteStatement) cVar.e();
                        for (T t : iterable) {
                            bindValues(sQLiteStatement, t);
                            if (z) {
                                updateKeyAfterInsertAndAttach(t, sQLiteStatement.executeInsert(), false);
                            } else {
                                sQLiteStatement.execute();
                            }
                        }
                    } else {
                        for (T t2 : iterable) {
                            bindValues(cVar, t2);
                            if (z) {
                                updateKeyAfterInsertAndAttach(t2, cVar.f(), false);
                            } else {
                                cVar.execute();
                            }
                        }
                    }
                } finally {
                    if (this.identityScope != null) {
                        this.identityScope.unlock();
                    }
                }
            }
            this.db.g();
        } finally {
            this.db.b();
        }
    }

    private long insertInsideTx(T t, i.b.a.i.c cVar) {
        synchronized (cVar) {
            if (!this.isStandardSQLite) {
                bindValues(cVar, t);
                return cVar.f();
            }
            SQLiteStatement sQLiteStatement = (SQLiteStatement) cVar.e();
            bindValues(sQLiteStatement, t);
            return sQLiteStatement.executeInsert();
        }
    }

    private void loadAllUnlockOnWindowBounds(Cursor cursor, CursorWindow cursorWindow, List<T> list) {
        int startPosition = cursorWindow.getStartPosition() + cursorWindow.getNumRows();
        int i2 = 0;
        while (true) {
            list.add(loadCurrent(cursor, 0, false));
            int i3 = i2 + 1;
            if (i3 >= startPosition) {
                CursorWindow cursorWindowMoveToNextUnlocked = moveToNextUnlocked(cursor);
                if (cursorWindowMoveToNextUnlocked == null) {
                    return;
                } else {
                    startPosition = cursorWindowMoveToNextUnlocked.getStartPosition() + cursorWindowMoveToNextUnlocked.getNumRows();
                }
            } else if (!cursor.moveToNext()) {
                return;
            }
            i2 = i3 + 1;
        }
    }

    private CursorWindow moveToNextUnlocked(Cursor cursor) {
        this.identityScope.unlock();
        try {
            return cursor.moveToNext() ? ((CrossProcessCursor) cursor).getWindow() : null;
        } finally {
            this.identityScope.lock();
        }
    }

    protected void assertSinglePk() {
        if (this.config.f4271i.length == 1) {
            return;
        }
        throw new d(this + " (" + this.config.f4268f + ") does not have a single-column primary key");
    }

    protected void attachEntity(T t) {
    }

    protected final void attachEntity(K k2, T t, boolean z) {
        attachEntity(t);
        i.b.a.j.a<K, T> aVar = this.identityScope;
        if (aVar == null || k2 == null) {
            return;
        }
        if (z) {
            aVar.put(k2, t);
        } else {
            aVar.a(k2, t);
        }
    }

    protected abstract void bindValues(SQLiteStatement sQLiteStatement, T t);

    protected abstract void bindValues(i.b.a.i.c cVar, T t);

    public long count() {
        return this.statements.a().a();
    }

    public void delete(T t) {
        assertSinglePk();
        deleteByKey(getKeyVerified(t));
    }

    public void deleteAll() {
        this.db.d("DELETE FROM '" + this.config.f4268f + "'");
        i.b.a.j.a<K, T> aVar = this.identityScope;
        if (aVar != null) {
            aVar.clear();
        }
    }

    public void deleteByKey(K k2) {
        assertSinglePk();
        i.b.a.i.c cVarB = this.statements.b();
        if (this.db.a()) {
            synchronized (cVarB) {
                deleteByKeyInsideSynchronized(k2, cVarB);
            }
        } else {
            this.db.c();
            try {
                synchronized (cVarB) {
                    deleteByKeyInsideSynchronized(k2, cVarB);
                }
                this.db.g();
            } finally {
                this.db.b();
            }
        }
        i.b.a.j.a<K, T> aVar = this.identityScope;
        if (aVar != null) {
            aVar.remove(k2);
        }
    }

    public void deleteByKeyInTx(Iterable<K> iterable) {
        deleteInTxInternal(null, iterable);
    }

    public void deleteInTx(Iterable<T> iterable) {
        deleteInTxInternal(iterable, null);
    }

    public boolean detach(T t) {
        if (this.identityScope == null) {
            return false;
        }
        return this.identityScope.b(getKeyVerified(t), t);
    }

    public void detachAll() {
        i.b.a.j.a<K, T> aVar = this.identityScope;
        if (aVar != null) {
            aVar.clear();
        }
    }

    public String[] getAllColumns() {
        return this.config.f4270h;
    }

    public i.b.a.i.a getDatabase() {
        return this.db;
    }

    protected abstract K getKey(T t);

    protected K getKeyVerified(T t) {
        K key = getKey(t);
        if (key != null) {
            return key;
        }
        if (t == null) {
            throw new NullPointerException("Entity may not be null");
        }
        throw new d("Entity has no key");
    }

    public String[] getNonPkColumns() {
        return this.config.f4272j;
    }

    public String[] getPkColumns() {
        return this.config.f4271i;
    }

    public g getPkProperty() {
        return this.config.f4273k;
    }

    public g[] getProperties() {
        return this.config.f4269g;
    }

    public c getSession() {
        return this.session;
    }

    i.b.a.k.e getStatements() {
        return this.config.m;
    }

    public String getTablename() {
        return this.config.f4268f;
    }

    public long insert(T t) {
        return executeInsert(t, this.statements.d(), true);
    }

    public void insertInTx(Iterable<T> iterable) {
        insertInTx(iterable, isEntityUpdateable());
    }

    public long insertOrReplace(T t) {
        return executeInsert(t, this.statements.c(), true);
    }

    public void insertOrReplaceInTx(Iterable<T> iterable, boolean z) {
        executeInsertInTx(this.statements.c(), iterable, z);
    }

    public long insertWithoutSettingPk(T t) {
        return executeInsert(t, this.statements.c(), false);
    }

    protected abstract boolean isEntityUpdateable();

    public T load(K k2) {
        T t;
        assertSinglePk();
        if (k2 == null) {
            return null;
        }
        i.b.a.j.a<K, T> aVar = this.identityScope;
        return (aVar == null || (t = aVar.get(k2)) == null) ? loadUniqueAndCloseCursor(this.db.h(this.statements.f(), new String[]{k2.toString()})) : t;
    }

    public List<T> loadAll() {
        return loadAllAndCloseCursor(this.db.h(this.statements.e(), null));
    }

    protected List<T> loadAllAndCloseCursor(Cursor cursor) {
        try {
            return loadAllFromCursor(cursor);
        } finally {
            cursor.close();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x007d  */
    /* JADX WARN: Removed duplicated region for block: B:39:? A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    protected java.util.List<T> loadAllFromCursor(android.database.Cursor r7) {
        /*
            r6 = this;
            int r0 = r7.getCount()
            if (r0 != 0) goto Lc
            java.util.ArrayList r7 = new java.util.ArrayList
            r7.<init>()
            return r7
        Lc:
            java.util.ArrayList r1 = new java.util.ArrayList
            r1.<init>(r0)
            r2 = 0
            boolean r3 = r7 instanceof android.database.CrossProcessCursor
            r4 = 0
            if (r3 == 0) goto L4d
            r2 = r7
            android.database.CrossProcessCursor r2 = (android.database.CrossProcessCursor) r2
            android.database.CursorWindow r2 = r2.getWindow()
            if (r2 == 0) goto L4d
            int r3 = r2.getNumRows()
            if (r3 != r0) goto L2d
            i.b.a.k.b r7 = new i.b.a.k.b
            r7.<init>(r2)
            r3 = 1
            goto L4e
        L2d:
            java.lang.StringBuilder r3 = new java.lang.StringBuilder
            r3.<init>()
            java.lang.String r5 = "Window vs. result size: "
            r3.append(r5)
            int r5 = r2.getNumRows()
            r3.append(r5)
            java.lang.String r5 = "/"
            r3.append(r5)
            r3.append(r0)
            java.lang.String r3 = r3.toString()
            i.b.a.e.a(r3)
        L4d:
            r3 = r4
        L4e:
            boolean r5 = r7.moveToFirst()
            if (r5 == 0) goto L8a
            i.b.a.j.a<K, T> r5 = r6.identityScope
            if (r5 == 0) goto L60
            r5.lock()
            i.b.a.j.a<K, T> r5 = r6.identityScope
            r5.e(r0)
        L60:
            if (r3 != 0) goto L6c
            if (r2 == 0) goto L6c
            i.b.a.j.a<K, T> r0 = r6.identityScope     // Catch: java.lang.Throwable -> L81
            if (r0 == 0) goto L6c
            r6.loadAllUnlockOnWindowBounds(r7, r2, r1)     // Catch: java.lang.Throwable -> L81
            goto L79
        L6c:
            java.lang.Object r0 = r6.loadCurrent(r7, r4, r4)     // Catch: java.lang.Throwable -> L81
            r1.add(r0)     // Catch: java.lang.Throwable -> L81
            boolean r0 = r7.moveToNext()     // Catch: java.lang.Throwable -> L81
            if (r0 != 0) goto L6c
        L79:
            i.b.a.j.a<K, T> r7 = r6.identityScope
            if (r7 == 0) goto L8a
            r7.unlock()
            goto L8a
        L81:
            r7 = move-exception
            i.b.a.j.a<K, T> r0 = r6.identityScope
            if (r0 == 0) goto L89
            r0.unlock()
        L89:
            throw r7
        L8a:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: i.b.a.a.loadAllFromCursor(android.database.Cursor):java.util.List");
    }

    public T loadByRowId(long j2) {
        return loadUniqueAndCloseCursor(this.db.h(this.statements.g(), new String[]{Long.toString(j2)}));
    }

    protected final T loadCurrent(Cursor cursor, int i2, boolean z) {
        if (this.identityScopeLong != null) {
            if (i2 != 0 && cursor.isNull(this.pkOrdinal + i2)) {
                return null;
            }
            long j2 = cursor.getLong(this.pkOrdinal + i2);
            i.b.a.j.b<T> bVar = this.identityScopeLong;
            T tH = z ? bVar.h(j2) : bVar.i(j2);
            if (tH != null) {
                return tH;
            }
            T entity = readEntity(cursor, i2);
            attachEntity(entity);
            if (z) {
                this.identityScopeLong.l(j2, entity);
            } else {
                this.identityScopeLong.m(j2, entity);
            }
            return entity;
        }
        if (this.identityScope == null) {
            if (i2 != 0 && readKey(cursor, i2) == null) {
                return null;
            }
            T entity2 = readEntity(cursor, i2);
            attachEntity(entity2);
            return entity2;
        }
        K key = readKey(cursor, i2);
        if (i2 != 0 && key == null) {
            return null;
        }
        i.b.a.j.a<K, T> aVar = this.identityScope;
        T tD = z ? aVar.get(key) : aVar.d(key);
        if (tD != null) {
            return tD;
        }
        T entity3 = readEntity(cursor, i2);
        attachEntity(key, entity3, z);
        return entity3;
    }

    protected final <O> O loadCurrentOther(a<O, ?> aVar, Cursor cursor, int i2) {
        return aVar.loadCurrent(cursor, i2, true);
    }

    protected T loadUnique(Cursor cursor) {
        if (!cursor.moveToFirst()) {
            return null;
        }
        if (cursor.isLast()) {
            return loadCurrent(cursor, 0, true);
        }
        throw new d("Expected unique result, but count was " + cursor.getCount());
    }

    protected T loadUniqueAndCloseCursor(Cursor cursor) {
        try {
            return loadUnique(cursor);
        } finally {
            cursor.close();
        }
    }

    public i.b.a.l.f<T> queryBuilder() {
        return i.b.a.l.f.i(this);
    }

    public List<T> queryRaw(String str, String... strArr) {
        return loadAllAndCloseCursor(this.db.h(this.statements.e() + str, strArr));
    }

    public i.b.a.l.e<T> queryRawCreate(String str, Object... objArr) {
        return queryRawCreateListArgs(str, Arrays.asList(objArr));
    }

    public i.b.a.l.e<T> queryRawCreateListArgs(String str, Collection<Object> collection) {
        return i.b.a.l.e.e(this, this.statements.e() + str, collection.toArray());
    }

    protected abstract T readEntity(Cursor cursor, int i2);

    protected abstract void readEntity(Cursor cursor, T t, int i2);

    protected abstract K readKey(Cursor cursor, int i2);

    public void refresh(T t) {
        assertSinglePk();
        K keyVerified = getKeyVerified(t);
        Cursor cursorH = this.db.h(this.statements.f(), new String[]{keyVerified.toString()});
        try {
            if (!cursorH.moveToFirst()) {
                throw new d("Entity does not exist in the database anymore: " + t.getClass() + " with key " + keyVerified);
            }
            if (cursorH.isLast()) {
                readEntity(cursorH, t, 0);
                attachEntity(keyVerified, t, true);
            } else {
                throw new d("Expected unique result, but count was " + cursorH.getCount());
            }
        } finally {
            cursorH.close();
        }
    }

    public void update(T t) {
        assertSinglePk();
        i.b.a.i.c cVarH = this.statements.h();
        if (this.db.a()) {
            synchronized (cVarH) {
                if (this.isStandardSQLite) {
                    updateInsideSynchronized((Object) t, (SQLiteStatement) cVarH.e(), true);
                } else {
                    updateInsideSynchronized((Object) t, cVarH, true);
                }
            }
            return;
        }
        this.db.c();
        try {
            synchronized (cVarH) {
                updateInsideSynchronized((Object) t, cVarH, true);
            }
            this.db.g();
        } finally {
            this.db.b();
        }
    }

    public void updateInTx(Iterable<T> iterable) {
        i.b.a.i.c cVarH = this.statements.h();
        this.db.c();
        try {
            synchronized (cVarH) {
                if (this.identityScope != null) {
                    this.identityScope.lock();
                }
                try {
                    if (this.isStandardSQLite) {
                        SQLiteStatement sQLiteStatement = (SQLiteStatement) cVarH.e();
                        Iterator<T> it = iterable.iterator();
                        while (it.hasNext()) {
                            updateInsideSynchronized((Object) it.next(), sQLiteStatement, false);
                        }
                    } else {
                        Iterator<T> it2 = iterable.iterator();
                        while (it2.hasNext()) {
                            updateInsideSynchronized((Object) it2.next(), cVarH, false);
                        }
                    }
                } finally {
                    if (this.identityScope != null) {
                        this.identityScope.unlock();
                    }
                }
            }
            this.db.g();
            try {
                this.db.b();
            } catch (RuntimeException e2) {
                throw e2;
            }
        } catch (RuntimeException e3) {
            try {
                this.db.b();
            } catch (RuntimeException e4) {
                e.f("Could not end transaction (rethrowing initial exception)", e4);
                throw e3;
            }
        } catch (Throwable th) {
            try {
                this.db.b();
                throw th;
            } catch (RuntimeException e5) {
                throw e5;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    protected void updateInsideSynchronized(T t, i.b.a.i.c cVar, boolean z) {
        bindValues(cVar, t);
        int length = this.config.f4270h.length + 1;
        Object key = getKey(t);
        if (key instanceof Long) {
            cVar.c(length, ((Long) key).longValue());
        } else {
            if (key == null) {
                throw new d("Cannot update entity without key - was it inserted before?");
            }
            cVar.b(length, key.toString());
        }
        cVar.execute();
        attachEntity(key, t, z);
    }

    protected abstract K updateKeyAfterInsert(T t, long j2);

    protected void updateKeyAfterInsertAndAttach(T t, long j2, boolean z) {
        if (j2 != -1) {
            attachEntity(updateKeyAfterInsert(t, j2), t, z);
        } else {
            e.e("Could not insert row (executeInsert returned -1)");
        }
    }

    public a(i.b.a.k.a aVar, c cVar) {
        this.config = aVar;
        this.session = cVar;
        i.b.a.i.a aVar2 = aVar.f4267b;
        this.db = aVar2;
        this.isStandardSQLite = aVar2.f() instanceof SQLiteDatabase;
        i.b.a.j.b<T> bVar = (i.b.a.j.a<K, T>) aVar.b();
        this.identityScope = bVar;
        if (bVar instanceof i.b.a.j.b) {
            this.identityScopeLong = bVar;
        }
        this.statements = aVar.m;
        g gVar = aVar.f4273k;
        this.pkOrdinal = gVar != null ? gVar.a : -1;
    }

    public void deleteByKeyInTx(K... kArr) {
        deleteInTxInternal(null, Arrays.asList(kArr));
    }

    public void deleteInTx(T... tArr) {
        deleteInTxInternal(Arrays.asList(tArr), null);
    }

    public void insertInTx(T... tArr) {
        insertInTx(Arrays.asList(tArr), isEntityUpdateable());
    }

    public void insertInTx(Iterable<T> iterable, boolean z) {
        executeInsertInTx(this.statements.d(), iterable, z);
    }

    public void insertOrReplaceInTx(Iterable<T> iterable) {
        insertOrReplaceInTx(iterable, isEntityUpdateable());
    }

    public void insertOrReplaceInTx(T... tArr) {
        insertOrReplaceInTx(Arrays.asList(tArr), isEntityUpdateable());
    }

    /* JADX WARN: Multi-variable type inference failed */
    protected void updateInsideSynchronized(T t, SQLiteStatement sQLiteStatement, boolean z) {
        bindValues(sQLiteStatement, t);
        int length = this.config.f4270h.length + 1;
        Object key = getKey(t);
        if (key instanceof Long) {
            sQLiteStatement.bindLong(length, ((Long) key).longValue());
        } else if (key != null) {
            sQLiteStatement.bindString(length, key.toString());
        } else {
            throw new d("Cannot update entity without key - was it inserted before?");
        }
        sQLiteStatement.execute();
        attachEntity(key, t, z);
    }

    public void updateInTx(T... tArr) {
        updateInTx(Arrays.asList(tArr));
    }
}
