what-the-bank/sources/o/PXI.java

128 lines
4.1 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import com.google.common.base.Preconditions;
import java.lang.reflect.Array;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.NoSuchElementException;
/* loaded from: classes2.dex */
public class PXI {
public static <T> T c(Class<T> cls) {
try {
return cls.newInstance();
} catch (IllegalAccessException e) {
throw d(e, cls);
} catch (InstantiationException e2) {
throw d(e2, cls);
}
}
private static IllegalArgumentException d(Exception exc, Class<?> cls) {
StringBuilder sb = new StringBuilder("unable to create new instance of class ");
sb.append(cls.getName());
ArrayList arrayList = new ArrayList();
boolean z = false;
if (cls.isArray()) {
arrayList.add("because it is an array");
} else if (cls.isPrimitive()) {
arrayList.add("because it is primitive");
} else if (cls == Void.class) {
arrayList.add("because it is void");
} else {
if (Modifier.isInterface(cls.getModifiers())) {
arrayList.add("because it is an interface");
} else if (Modifier.isAbstract(cls.getModifiers())) {
arrayList.add("because it is abstract");
}
if (cls.getEnclosingClass() != null && !Modifier.isStatic(cls.getModifiers())) {
arrayList.add("because it is not static");
}
if (!Modifier.isPublic(cls.getModifiers())) {
arrayList.add("possibly because it is not public");
} else {
try {
cls.getConstructor(new Class[0]);
} catch (NoSuchMethodException unused) {
arrayList.add("because it has no accessible default constructor");
}
}
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
String str = (String) it.next();
if (z) {
sb.append(" and");
} else {
z = true;
}
sb.append(" ");
sb.append(str);
}
return new IllegalArgumentException(sb.toString(), exc);
}
public static <T> Iterable<T> c(Object obj) {
if (obj instanceof Iterable) {
return (Iterable) obj;
}
Class<?> cls = obj.getClass();
Preconditions.checkArgument(cls.isArray(), "not an array or Iterable: %s", cls);
if (!cls.getComponentType().isPrimitive()) {
return Arrays.asList((Object[]) obj);
}
return new AnonymousClass4(obj);
}
/* JADX INFO: Add missing generic type declarations: [T] */
/* renamed from: o.PXI$4, reason: invalid class name */
/* loaded from: classes2.dex */
static final class AnonymousClass4<T> implements Iterable<T> {
final Object c;
AnonymousClass4(Object obj) {
this.c = obj;
}
@Override // java.lang.Iterable
public final Iterator<T> iterator() {
return new Iterator<T>(this) { // from class: o.PXI.4.4
private int a;
private int b = 0;
private AnonymousClass4 e;
{
this.e = this;
this.a = Array.getLength(this.c);
}
@Override // java.util.Iterator
public final T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Object obj = this.e.c;
int i = this.b;
this.b = i + 1;
return (T) Array.get(obj, i);
}
@Override // java.util.Iterator
public final void remove() {
throw new UnsupportedOperationException();
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.b < this.a;
}
};
}
}
private PXI() {
}
}