package g.d.a.t;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Optional;

/* JADX INFO: loaded from: classes.dex */
public abstract class c {
    public static List<Object> f(Object obj) {
        g.d.a.v.c cVar = new g.d.a.v.c();
        cVar.add(obj);
        return cVar;
    }

    public Object a(Object obj) {
        if (!(obj instanceof Optional)) {
            return obj;
        }
        Optional optional = (Optional) obj;
        if (optional.isPresent()) {
            return a(optional.get());
        }
        return null;
    }

    public abstract g.d.a.v.d b(String str, List<Object> list);

    public AccessibleObject c(Class cls, String str) {
        AccessibleObject accessibleObjectC;
        if (String.class == cls && "value".equals(str)) {
            return null;
        }
        if ((cls.getModifiers() & 1) != 1) {
            for (Class<?> cls2 : cls.getInterfaces()) {
                AccessibleObject accessibleObjectC2 = c(cls2, str);
                if (accessibleObjectC2 != null) {
                    return accessibleObjectC2;
                }
            }
            Class superclass = cls.getSuperclass();
            if (superclass != null && superclass != Object.class && (accessibleObjectC = c(superclass, str)) != null) {
                return accessibleObjectC;
            }
        }
        try {
            return e(cls, str, new Class[0]);
        } catch (NoSuchMethodException unused) {
            StringBuilder sb = new StringBuilder();
            sb.append(str.substring(0, 1).toUpperCase());
            sb.append(str.length() > 1 ? str.substring(1) : "");
            String string = sb.toString();
            try {
                try {
                    try {
                        return e(cls, "get" + string, new Class[0]);
                    } catch (NoSuchMethodException unused2) {
                        return d(cls, str);
                    }
                } catch (NoSuchFieldException unused3) {
                    return null;
                }
            } catch (NoSuchMethodException unused4) {
                return e(cls, "is" + string, new Class[0]);
            }
        }
    }

    public Field d(Class cls, String str) throws NoSuchFieldException {
        try {
            Field declaredField = cls.getDeclaredField(str);
            if ((declaredField.getModifiers() & 2) == 2) {
                throw new NoSuchFieldException("Only public, protected and package members allowed");
            }
            declaredField.setAccessible(true);
            return declaredField;
        } catch (NoSuchFieldException e2) {
            Class superclass = cls.getSuperclass();
            if (superclass == null || superclass == Object.class) {
                throw e2;
            }
            return d(superclass, str);
        }
    }

    public Method e(Class<?> cls, String str, Class<?>... clsArr) throws NoSuchMethodException {
        Method declaredMethod;
        try {
            try {
                declaredMethod = cls.getMethod(str, clsArr);
                if (declaredMethod.getDeclaringClass() == Object.class) {
                    throw new NoSuchMethodException();
                }
            } catch (NoSuchMethodException e2) {
                Class<? super Object> superclass = cls.getSuperclass();
                if (superclass == null || superclass == Object.class) {
                    throw e2;
                }
                return e(superclass, str, new Class[0]);
            }
        } catch (NoSuchMethodException unused) {
            declaredMethod = cls.getDeclaredMethod(str, clsArr);
        }
        if ((declaredMethod.getModifiers() & 2) == 2) {
            throw new NoSuchMethodException("Only public, protected and package members allowed");
        }
        declaredMethod.setAccessible(true);
        return declaredMethod;
    }
}
