package h;

import d.C0424d;
import g.C0474a;
import g.InterfaceC0476c;
import java.lang.reflect.Type;
import java.math.BigDecimal;

/* JADX INFO: loaded from: classes.dex */
public class s implements t {

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

    @Override // h.t
    public Object b(C0474a c0474a, Type type, Object obj) {
        InterfaceC0476c interfaceC0476c = c0474a.f3944H;
        if (interfaceC0476c.F() == 2) {
            if (type == Double.TYPE || type == Double.class) {
                String strA0 = interfaceC0476c.a0();
                interfaceC0476c.s(16);
                return Double.valueOf(Double.parseDouble(strA0));
            }
            long jD = interfaceC0476c.d();
            interfaceC0476c.s(16);
            if (type == Short.TYPE || type == Short.class) {
                if (jD <= 32767 && jD >= -32768) {
                    return Short.valueOf((short) jD);
                }
                throw new C0424d("short overflow : " + jD);
            }
            if (type != Byte.TYPE && type != Byte.class) {
                return (jD < -2147483648L || jD > 2147483647L) ? Long.valueOf(jD) : Integer.valueOf((int) jD);
            }
            if (jD <= 127 && jD >= -128) {
                return Byte.valueOf((byte) jD);
            }
            throw new C0424d("short overflow : " + jD);
        }
        if (interfaceC0476c.F() == 3) {
            if (type == Double.TYPE || type == Double.class) {
                String strA02 = interfaceC0476c.a0();
                interfaceC0476c.s(16);
                return Double.valueOf(Double.parseDouble(strA02));
            }
            if (type == Short.TYPE || type == Short.class) {
                BigDecimal bigDecimalT = interfaceC0476c.t();
                interfaceC0476c.s(16);
                return Short.valueOf(l.l.L0(bigDecimalT));
            }
            if (type == Byte.TYPE || type == Byte.class) {
                BigDecimal bigDecimalT2 = interfaceC0476c.t();
                interfaceC0476c.s(16);
                return Byte.valueOf(l.l.e(bigDecimalT2));
            }
            BigDecimal bigDecimalT3 = interfaceC0476c.t();
            interfaceC0476c.s(16);
            return bigDecimalT3;
        }
        if (interfaceC0476c.F() == 18 && "NaN".equals(interfaceC0476c.A())) {
            interfaceC0476c.i();
            if (type == Double.class) {
                return Double.valueOf(Double.NaN);
            }
            if (type == Float.class) {
                return Float.valueOf(Float.NaN);
            }
            return null;
        }
        Object objA = c0474a.A();
        if (objA == null) {
            return null;
        }
        if (type == Double.TYPE || type == Double.class) {
            try {
                return l.l.q(objA);
            } catch (Exception e2) {
                throw new C0424d("parseDouble error, field : " + obj, e2);
            }
        }
        if (type == Short.TYPE || type == Short.class) {
            try {
                return l.l.x(objA);
            } catch (Exception e3) {
                throw new C0424d("parseShort error, field : " + obj, e3);
            }
        }
        if (type != Byte.TYPE && type != Byte.class) {
            return l.l.i(objA);
        }
        try {
            return l.l.l(objA);
        } catch (Exception e4) {
            throw new C0424d("parseByte error, field : " + obj, e4);
        }
    }

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