package i;

import d.C0422b;
import g.C0474a;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.HashSet;
import java.util.TreeSet;

/* JADX INFO: renamed from: i.t, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0539t implements U, h.t {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final C0539t f4380a = new C0539t();

    @Override // i.U
    public void a(C0516I c0516i, Object obj, Object obj2, Type type, int i2) {
        e0 e0Var = c0516i.f4223k;
        if (obj == null) {
            e0Var.N(f0.WriteNullListAsEmpty);
            return;
        }
        f0 f0Var = f0.WriteClassName;
        Type typeU = (e0Var.j(f0Var) || f0.isEnabled(i2, f0Var)) ? l.l.U(type) : null;
        Collection collection = (Collection) obj;
        Z z2 = c0516i.f4229q;
        int i3 = 0;
        c0516i.s(z2, obj, obj2, 0);
        if (e0Var.j(f0Var)) {
            if (HashSet.class.isAssignableFrom(collection.getClass())) {
                e0Var.append("Set");
            } else if (TreeSet.class == collection.getClass()) {
                e0Var.append("TreeSet");
            }
        }
        try {
            e0Var.append('[');
            for (Object obj3 : collection) {
                int i4 = i3 + 1;
                if (i3 != 0) {
                    e0Var.append(',');
                }
                if (obj3 == null) {
                    e0Var.K();
                } else {
                    Class<?> cls = obj3.getClass();
                    if (cls == Integer.class) {
                        e0Var.G(((Integer) obj3).intValue());
                    } else if (cls == Long.class) {
                        e0Var.I(((Long) obj3).longValue());
                        if (e0Var.j(f0.WriteClassName)) {
                            e0Var.write(76);
                        }
                    } else {
                        U uM = c0516i.m(cls);
                        if (f0.isEnabled(i2, f0.WriteClassName) && (uM instanceof C0517J)) {
                            ((C0517J) uM).u(c0516i, obj3, Integer.valueOf(i3), typeU, i2);
                        } else {
                            uM.a(c0516i, obj3, Integer.valueOf(i3), typeU, i2);
                        }
                    }
                }
                i3 = i4;
            }
            e0Var.append(']');
            c0516i.f4229q = z2;
        } catch (Throwable th) {
            c0516i.f4229q = z2;
            throw th;
        }
    }

    @Override // h.t
    public Object b(C0474a c0474a, Type type, Object obj) {
        if (c0474a.f3944H.F() == 8) {
            c0474a.f3944H.s(16);
            return null;
        }
        if (type == C0422b.class) {
            C0422b c0422b = new C0422b();
            c0474a.H(c0422b);
            return c0422b;
        }
        Collection collectionG = l.l.G(type);
        c0474a.G(l.l.U(type), collectionG, obj);
        return collectionG;
    }

    @Override // h.t
    public int d() {
        return 14;
    }
}
