package i.b.a.k;

import i.b.a.g;
import java.lang.reflect.Field;
import java.util.ArrayList;

/* JADX INFO: compiled from: DaoConfig.java */
/* JADX INFO: loaded from: classes.dex */
public final class a implements Cloneable {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final i.b.a.i.a f4267b;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final String f4268f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final g[] f4269g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final String[] f4270h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final String[] f4271i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final String[] f4272j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final g f4273k;
    public final boolean l;
    public final e m;
    private i.b.a.j.a<?, ?> n;

    public a(i.b.a.i.a aVar, Class<? extends i.b.a.a<?, ?>> cls) {
        this.f4267b = aVar;
        try {
            this.f4268f = (String) cls.getField("TABLENAME").get(null);
            g[] gVarArrE = e(cls);
            this.f4269g = gVarArrE;
            this.f4270h = new String[gVarArrE.length];
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            g gVar = null;
            for (int i2 = 0; i2 < gVarArrE.length; i2++) {
                g gVar2 = gVarArrE[i2];
                String str = gVar2.f4248e;
                this.f4270h[i2] = str;
                if (gVar2.f4247d) {
                    arrayList.add(str);
                    gVar = gVar2;
                } else {
                    arrayList2.add(str);
                }
            }
            this.f4272j = (String[]) arrayList2.toArray(new String[arrayList2.size()]);
            String[] strArr = (String[]) arrayList.toArray(new String[arrayList.size()]);
            this.f4271i = strArr;
            this.f4273k = strArr.length == 1 ? gVar : null;
            this.m = new e(aVar, this.f4268f, this.f4270h, this.f4271i);
            if (this.f4273k == null) {
                this.l = false;
            } else {
                Class<?> cls2 = this.f4273k.f4245b;
                this.l = cls2.equals(Long.TYPE) || cls2.equals(Long.class) || cls2.equals(Integer.TYPE) || cls2.equals(Integer.class) || cls2.equals(Short.TYPE) || cls2.equals(Short.class) || cls2.equals(Byte.TYPE) || cls2.equals(Byte.class);
            }
        } catch (Exception e2) {
            throw new i.b.a.d("Could not init DAOConfig", e2);
        }
    }

    private static g[] e(Class<? extends i.b.a.a<?, ?>> cls) throws IllegalAccessException, ClassNotFoundException, IllegalArgumentException {
        Field[] declaredFields = Class.forName(cls.getName() + "$Properties").getDeclaredFields();
        ArrayList<g> arrayList = new ArrayList();
        for (Field field : declaredFields) {
            if ((field.getModifiers() & 9) == 9) {
                Object obj = field.get(null);
                if (obj instanceof g) {
                    arrayList.add((g) obj);
                }
            }
        }
        g[] gVarArr = new g[arrayList.size()];
        for (g gVar : arrayList) {
            int i2 = gVar.a;
            if (gVarArr[i2] != null) {
                throw new i.b.a.d("Duplicate property ordinals");
            }
            gVarArr[i2] = gVar;
        }
        return gVarArr;
    }

    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public a clone() {
        return new a(this);
    }

    public i.b.a.j.a<?, ?> b() {
        return this.n;
    }

    public void c(i.b.a.j.d dVar) {
        if (dVar == i.b.a.j.d.None) {
            this.n = null;
            return;
        }
        if (dVar != i.b.a.j.d.Session) {
            throw new IllegalArgumentException("Unsupported type: " + dVar);
        }
        if (this.l) {
            this.n = new i.b.a.j.b();
        } else {
            this.n = new i.b.a.j.c();
        }
    }

    public a(a aVar) {
        this.f4267b = aVar.f4267b;
        this.f4268f = aVar.f4268f;
        this.f4269g = aVar.f4269g;
        this.f4270h = aVar.f4270h;
        this.f4271i = aVar.f4271i;
        this.f4272j = aVar.f4272j;
        this.f4273k = aVar.f4273k;
        this.m = aVar.m;
        this.l = aVar.l;
    }
}
