package com.seewo.hiddenapi.c;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;

/* JADX INFO: compiled from: Reflect.java */
/* JADX INFO: loaded from: classes.dex */
class b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final Class<?> f2450a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final Object f2451b;

    private b(Class<?> cls) {
        this(cls, cls);
    }

    public static <T extends AccessibleObject> T a(T t) {
        if (t == null) {
            return null;
        }
        if (t instanceof Member) {
            Member member = (Member) t;
            if (Modifier.isPublic(member.getModifiers()) && Modifier.isPublic(member.getDeclaringClass().getModifiers())) {
                return t;
            }
        }
        if (!t.isAccessible()) {
            t.setAccessible(true);
        }
        return t;
    }

    private Field c(String str) throws c {
        Class<?> clsG = g();
        try {
            return (Field) a(clsG.getField(str));
        } catch (NoSuchFieldException e2) {
            do {
                try {
                    return (Field) a(clsG.getDeclaredField(str));
                } catch (NoSuchFieldException unused) {
                    clsG = clsG.getSuperclass();
                    if (clsG == null) {
                        throw new c(e2);
                    }
                }
            } while (clsG == null);
            throw new c(e2);
        }
    }

    public static b e(Class<?> cls) {
        return new b(cls);
    }

    private static b f(Class<?> cls, Object obj) {
        return new b(cls, obj);
    }

    public b b(String str) throws c {
        try {
            Field fieldC = c(str);
            return f(fieldC.getType(), fieldC.get(this.f2451b));
        } catch (Exception e2) {
            throw new c(e2);
        }
    }

    public <T> T d() {
        return (T) this.f2451b;
    }

    public boolean equals(Object obj) {
        if (obj instanceof b) {
            return this.f2451b.equals(((b) obj).d());
        }
        return false;
    }

    public Class<?> g() {
        return this.f2450a;
    }

    public int hashCode() {
        return this.f2451b.hashCode();
    }

    public String toString() {
        return this.f2451b.toString();
    }

    private b(Class<?> cls, Object obj) {
        this.f2450a = cls;
        this.f2451b = obj;
    }
}
