what-the-bank/sources/com/huawei/hms/common/internal/Preconditions.java

64 lines
1.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.common.internal;
import android.os.Handler;
import android.os.Looper;
/* loaded from: classes2.dex */
public final class Preconditions {
private Preconditions() {
throw new AssertionError("Cannot use constructor to make a new instance");
}
private static boolean a() {
return Looper.getMainLooper() == Looper.myLooper();
}
public static void checkArgument(boolean z, Object obj) {
if (!z) {
throw new IllegalArgumentException(String.valueOf(obj));
}
}
public static void checkHandlerThread(Handler handler) {
checkHandlerThread(handler, "Must be called on the handler thread");
}
public static void checkMainThread(String str) {
if (!a()) {
throw new IllegalStateException(str);
}
}
public static void checkNotMainThread() {
if (a()) {
throw new IllegalStateException("Must not be called on the main application thread");
}
}
public static <O> O checkNotNull(O o2) {
if (o2 != null) {
return o2;
}
throw new NullPointerException("must not refer to a null object");
}
public static void checkState(boolean z, Object obj) {
if (!z) {
throw new IllegalStateException(String.valueOf(obj));
}
}
public static void checkHandlerThread(Handler handler, String str) {
if (Looper.myLooper() != handler.getLooper()) {
throw new IllegalStateException(str);
}
}
public static <O> O checkNotNull(O o2, Object obj) {
if (o2 != null) {
return o2;
}
throw new NullPointerException(String.valueOf(obj));
}
}