222 lines
7.2 KiB
Java
222 lines
7.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;
|
|
|
|
/* JADX INFO: compiled from: com.google.android.gms:play-services-basement@@18.3.0 */
|
|
/* JADX INFO: loaded from: classes2.dex */
|
|
public final class Preconditions {
|
|
private Preconditions() {
|
|
throw new AssertionError("Uninstantiable");
|
|
}
|
|
|
|
public static void checkArgument(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
|
|
public static double checkArgumentInRange(double d, double d2, double d3, String str) {
|
|
if (d < d2) {
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too low)", str, Double.valueOf(d2), Double.valueOf(d3)));
|
|
}
|
|
if (d <= d3) {
|
|
return d;
|
|
}
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too high)", str, Double.valueOf(d2), Double.valueOf(d3)));
|
|
}
|
|
|
|
public static void checkHandlerThread(Handler handler) {
|
|
Looper looperMyLooper = Looper.myLooper();
|
|
if (looperMyLooper != handler.getLooper()) {
|
|
String name = looperMyLooper != null ? looperMyLooper.getThread().getName() : "null current looper";
|
|
throw new IllegalStateException("Must be called on " + handler.getLooper().getThread().getName() + " thread, but got " + name + ".");
|
|
}
|
|
}
|
|
|
|
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 checkNotGoogleApiHandlerThread() {
|
|
checkNotGoogleApiHandlerThread("Must not be called on GoogleApiHandler thread.");
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
static String zza(String str, Object... objArr) {
|
|
int iIndexOf;
|
|
StringBuilder sb = new StringBuilder(str.length() + 48);
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < 3 && (iIndexOf = str.indexOf("%s", i2)) != -1) {
|
|
sb.append(str.substring(i2, iIndexOf));
|
|
sb.append(objArr[i]);
|
|
i2 = iIndexOf + 2;
|
|
i++;
|
|
}
|
|
sb.append(str.substring(i2));
|
|
if (i < 3) {
|
|
sb.append(" [");
|
|
sb.append(objArr[i]);
|
|
for (int i3 = i + 1; i3 < 3; i3++) {
|
|
sb.append(", ");
|
|
sb.append(objArr[i3]);
|
|
}
|
|
sb.append("]");
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
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 checkNotGoogleApiHandlerThread(String str) {
|
|
Looper looperMyLooper = Looper.myLooper();
|
|
if (looperMyLooper != null) {
|
|
String name = looperMyLooper.getThread().getName();
|
|
if (name == "GoogleApiHandler" || (name != null && name.equals("GoogleApiHandler"))) {
|
|
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));
|
|
}
|
|
}
|
|
|
|
public static float checkArgumentInRange(float f, float f2, float f3, String str) {
|
|
if (f < f2) {
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too low)", str, Float.valueOf(f2), Float.valueOf(f3)));
|
|
}
|
|
if (f <= f3) {
|
|
return f;
|
|
}
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%f, %f] (too high)", str, Float.valueOf(f2), Float.valueOf(f3)));
|
|
}
|
|
|
|
@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 int checkArgumentInRange(int i, int i2, int i3, String str) {
|
|
if (i < i2) {
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too low)", str, Integer.valueOf(i2), Integer.valueOf(i3)));
|
|
}
|
|
if (i <= i3) {
|
|
return i;
|
|
}
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too high)", str, Integer.valueOf(i2), Integer.valueOf(i3)));
|
|
}
|
|
|
|
public static void checkHandlerThread(Handler handler, String str) {
|
|
if (Looper.myLooper() != handler.getLooper()) {
|
|
throw new IllegalStateException(str);
|
|
}
|
|
}
|
|
|
|
public static long checkArgumentInRange(long j, long j2, long j3, String str) {
|
|
if (j < j2) {
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too low)", str, Long.valueOf(j2), Long.valueOf(j3)));
|
|
}
|
|
if (j <= j3) {
|
|
return j;
|
|
}
|
|
throw new IllegalArgumentException(zza("%s is out of range of [%d, %d] (too high)", str, Long.valueOf(j2), Long.valueOf(j3)));
|
|
}
|
|
} |