what-the-bank/sources/com/facetec/sdk/mj.java

109 lines
3.3 KiB
Java

package com.facetec.sdk;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
final class mj<T> {
private final Class[] c;
private final Class<?> d;
private final String e;
/* JADX INFO: Access modifiers changed from: package-private */
public mj(Class<?> cls, String str, Class... clsArr) {
this.d = cls;
this.e = str;
this.c = clsArr;
}
public final boolean c(T t) {
return e(t.getClass()) != null;
}
private Object d(T t, Object... objArr) throws InvocationTargetException {
Method e = e(t.getClass());
if (e == null) {
return null;
}
try {
return e.invoke(t, objArr);
} catch (IllegalAccessException unused) {
return null;
}
}
public final Object e(T t, Object... objArr) {
try {
return d(t, objArr);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if (targetException instanceof RuntimeException) {
throw ((RuntimeException) targetException);
}
AssertionError assertionError = new AssertionError("Unexpected exception");
assertionError.initCause(targetException);
throw assertionError;
}
}
private Object c(T t, Object... objArr) throws InvocationTargetException {
Method e = e(t.getClass());
if (e == null) {
StringBuilder sb = new StringBuilder("Method ");
sb.append(this.e);
sb.append(" not supported for object ");
sb.append(t);
throw new AssertionError(sb.toString());
}
try {
return e.invoke(t, objArr);
} catch (IllegalAccessException e2) {
AssertionError assertionError = new AssertionError("Unexpectedly could not call: ".concat(String.valueOf(e)));
assertionError.initCause(e2);
throw assertionError;
}
}
public final Object a(T t, Object... objArr) {
try {
return c(t, objArr);
} catch (InvocationTargetException e) {
Throwable targetException = e.getTargetException();
if (targetException instanceof RuntimeException) {
throw ((RuntimeException) targetException);
}
AssertionError assertionError = new AssertionError("Unexpected exception");
assertionError.initCause(targetException);
throw assertionError;
}
}
private Method e(Class<?> cls) {
Class<?> cls2;
String str = this.e;
if (str == null) {
return null;
}
Method a = a(cls, str, this.c);
if (a == null || (cls2 = this.d) == null || cls2.isAssignableFrom(a.getReturnType())) {
return a;
}
return null;
}
private static Method a(Class<?> cls, String str, Class[] clsArr) {
try {
Method method = cls.getMethod(str, clsArr);
try {
if ((method.getModifiers() & 1) == 0) {
return null;
}
} catch (NoSuchMethodException unused) {
}
return method;
} catch (NoSuchMethodException unused2) {
return null;
}
}
}