package d.e.g.p;

import android.text.TextUtils;
import com.seewo.sdk.internal.model.SDKParsable;
import com.seewo.sdk.internal.model.SDKResponse;
import com.seewo.sdk.internal.response.common.RespBooleanResult;
import com.seewo.sdk.internal.response.common.RespStringResult;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/* JADX INFO: compiled from: ParseUtil.java */
/* JADX INFO: loaded from: classes.dex */
public class b {
    private static <T> T a(Class<T> cls) {
        try {
            Constructor<T> declaredConstructor = cls.getDeclaredConstructor(new Class[0]);
            if (declaredConstructor == null) {
                return null;
            }
            declaredConstructor.setAccessible(true);
            return declaredConstructor.newInstance(new Object[0]);
        } catch (IllegalAccessException e2) {
            d.d("ParseUtil", e2);
            return null;
        } catch (InstantiationException e3) {
            d.d("ParseUtil", e3);
            return null;
        } catch (NoSuchMethodException e4) {
            d.d("ParseUtil", e4);
            return null;
        } catch (InvocationTargetException e5) {
            d.d("ParseUtil", e5);
            return null;
        }
    }

    public static boolean b(SDKResponse sDKResponse) {
        RespBooleanResult respBooleanResult;
        return (sDKResponse == null || (respBooleanResult = (RespBooleanResult) c(sDKResponse, RespBooleanResult.class)) == null || !respBooleanResult.getResult()) ? false : true;
    }

    public static <T> T c(SDKResponse sDKResponse, Class<T> cls) {
        if (sDKResponse == null) {
            return (T) a(cls);
        }
        if (sDKResponse.getStatus() == SDKResponse.Status.SUCCESS) {
            T t = (T) d.a.a.a.j(sDKResponse.getParamsJson(), cls);
            return t == null ? (T) a(cls) : t;
        }
        d.b("ParseUtil", "Response error! [ " + sDKResponse.getStatus() + " ]");
        return (T) a(cls);
    }

    public static <T> T d(String str, Class<T> cls) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        return (T) d.a.a.a.j(str, cls);
    }

    public static String e(SDKResponse sDKResponse) {
        RespStringResult respStringResult;
        if (sDKResponse == null || (respStringResult = (RespStringResult) c(sDKResponse, RespStringResult.class)) == null) {
            return null;
        }
        return respStringResult.getResult();
    }

    public static String f(Object obj) {
        return d.a.a.a.o(obj);
    }

    public static String g(SDKParsable sDKParsable) {
        return sDKParsable.getClass().getName();
    }
}
