150 lines
4.2 KiB
Java
150 lines
4.2 KiB
Java
package com.google.android.gms.common.internal;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.text.TextUtils;
|
|
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Preconditions {
|
|
private Preconditions() {
|
|
throw new AssertionError("Uninstantiable");
|
|
}
|
|
|
|
public static void checkArgument(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
|
|
public static void checkHandlerThread(Handler handler) {
|
|
Looper myLooper = Looper.myLooper();
|
|
if (myLooper != handler.getLooper()) {
|
|
String name = myLooper != null ? myLooper.getThread().getName() : "null current looper";
|
|
String name2 = handler.getLooper().getThread().getName();
|
|
StringBuilder sb = new StringBuilder("Must be called on ");
|
|
sb.append(name2);
|
|
sb.append(" thread, but got ");
|
|
sb.append(name);
|
|
sb.append(".");
|
|
throw new IllegalStateException(sb.toString());
|
|
}
|
|
}
|
|
|
|
public static void checkMainThread() {
|
|
checkMainThread("Must be called on the main application thread");
|
|
}
|
|
|
|
@EnsuresNonNull({"#1"})
|
|
public static String checkNotEmpty(String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
throw new IllegalArgumentException("Given String is empty or null");
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public static void checkNotMainThread() {
|
|
checkNotMainThread("Must not be called on the main application thread");
|
|
}
|
|
|
|
@EnsuresNonNull({"#1"})
|
|
public static <T> T checkNotNull(T t) {
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new NullPointerException("null reference");
|
|
}
|
|
|
|
public static int checkNotZero(int i) {
|
|
if (i != 0) {
|
|
return i;
|
|
}
|
|
throw new IllegalArgumentException("Given Integer is zero");
|
|
}
|
|
|
|
public static void checkState(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
public static void checkArgument(boolean z, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(String.valueOf(obj));
|
|
}
|
|
}
|
|
|
|
public static void checkMainThread(String str) {
|
|
if (!com.google.android.gms.common.util.zzb.zza()) {
|
|
throw new IllegalStateException(str);
|
|
}
|
|
}
|
|
|
|
public static void checkNotMainThread(String str) {
|
|
if (com.google.android.gms.common.util.zzb.zza()) {
|
|
throw new IllegalStateException(str);
|
|
}
|
|
}
|
|
|
|
@EnsuresNonNull({"#1"})
|
|
public static <T> T checkNotNull(T t, Object obj) {
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new NullPointerException(String.valueOf(obj));
|
|
}
|
|
|
|
public static int checkNotZero(int i, Object obj) {
|
|
if (i != 0) {
|
|
return i;
|
|
}
|
|
throw new IllegalArgumentException(String.valueOf(obj));
|
|
}
|
|
|
|
public static void checkState(boolean z, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalStateException(String.valueOf(obj));
|
|
}
|
|
}
|
|
|
|
public static void checkArgument(boolean z, String str, Object... objArr) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(String.format(str, objArr));
|
|
}
|
|
}
|
|
|
|
@EnsuresNonNull({"#1"})
|
|
public static String checkNotEmpty(String str, Object obj) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
throw new IllegalArgumentException(String.valueOf(obj));
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public static long checkNotZero(long j) {
|
|
if (j != 0) {
|
|
return j;
|
|
}
|
|
throw new IllegalArgumentException("Given Long is zero");
|
|
}
|
|
|
|
public static void checkState(boolean z, String str, Object... objArr) {
|
|
if (!z) {
|
|
throw new IllegalStateException(String.format(str, objArr));
|
|
}
|
|
}
|
|
|
|
public static long checkNotZero(long j, Object obj) {
|
|
if (j != 0) {
|
|
return j;
|
|
}
|
|
throw new IllegalArgumentException(String.valueOf(obj));
|
|
}
|
|
|
|
public static void checkHandlerThread(Handler handler, String str) {
|
|
if (Looper.myLooper() != handler.getLooper()) {
|
|
throw new IllegalStateException(str);
|
|
}
|
|
}
|
|
}
|