180 lines
5.1 KiB
Java
180 lines
5.1 KiB
Java
package com.google.common.base;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Preconditions {
|
|
public static void a(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
|
|
public static void b(boolean z) {
|
|
if (!z) {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
|
|
public static int c(int i, int i2, String str) {
|
|
if (i < 0 || i >= i2) {
|
|
throw new IndexOutOfBoundsException(a(i, i2, str));
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static int d(int i, int i2, String str) {
|
|
if (i < 0 || i > i2) {
|
|
throw new IndexOutOfBoundsException(b(i, i2, str));
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static void a(boolean z, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(String.valueOf(obj));
|
|
}
|
|
}
|
|
|
|
public static void b(boolean z, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalStateException(String.valueOf(obj));
|
|
}
|
|
}
|
|
|
|
public static void a(boolean z, String str, int i) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, Integer.valueOf(i)));
|
|
}
|
|
}
|
|
|
|
public static void b(boolean z, String str, int i) {
|
|
if (!z) {
|
|
throw new IllegalStateException(a(str, Integer.valueOf(i)));
|
|
}
|
|
}
|
|
|
|
public static void a(boolean z, String str, long j) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, Long.valueOf(j)));
|
|
}
|
|
}
|
|
|
|
public static void b(boolean z, String str, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalStateException(a(str, obj));
|
|
}
|
|
}
|
|
|
|
public static void a(boolean z, String str, Object obj) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, obj));
|
|
}
|
|
}
|
|
|
|
public static int b(int i, int i2) {
|
|
d(i, i2, "index");
|
|
return i;
|
|
}
|
|
|
|
public static void a(boolean z, String str, int i, int i2) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, Integer.valueOf(i), Integer.valueOf(i2)));
|
|
}
|
|
}
|
|
|
|
private static String b(int i, int i2, String str) {
|
|
if (i < 0) {
|
|
return a("%s (%s) must not be negative", str, Integer.valueOf(i));
|
|
}
|
|
if (i2 >= 0) {
|
|
return a("%s (%s) must not be greater than size (%s)", str, Integer.valueOf(i), Integer.valueOf(i2));
|
|
}
|
|
throw new IllegalArgumentException("negative size: " + i2);
|
|
}
|
|
|
|
public static void a(boolean z, String str, long j, long j2) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, Long.valueOf(j), Long.valueOf(j2)));
|
|
}
|
|
}
|
|
|
|
public static void a(boolean z, String str, Object obj, Object obj2) {
|
|
if (!z) {
|
|
throw new IllegalArgumentException(a(str, obj, obj2));
|
|
}
|
|
}
|
|
|
|
public static <T> T a(T t) {
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new NullPointerException();
|
|
}
|
|
|
|
public static void b(int i, int i2, int i3) {
|
|
if (i < 0 || i2 < i || i2 > i3) {
|
|
throw new IndexOutOfBoundsException(a(i, i2, i3));
|
|
}
|
|
}
|
|
|
|
public static <T> T a(T t, Object obj) {
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new NullPointerException(String.valueOf(obj));
|
|
}
|
|
|
|
public static <T> T a(T t, String str, Object obj, Object obj2) {
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
throw new NullPointerException(a(str, obj, obj2));
|
|
}
|
|
|
|
public static int a(int i, int i2) {
|
|
c(i, i2, "index");
|
|
return i;
|
|
}
|
|
|
|
private static String a(int i, int i2, String str) {
|
|
if (i < 0) {
|
|
return a("%s (%s) must not be negative", str, Integer.valueOf(i));
|
|
}
|
|
if (i2 >= 0) {
|
|
return a("%s (%s) must be less than size (%s)", str, Integer.valueOf(i), Integer.valueOf(i2));
|
|
}
|
|
throw new IllegalArgumentException("negative size: " + i2);
|
|
}
|
|
|
|
private static String a(int i, int i2, int i3) {
|
|
if (i < 0 || i > i3) {
|
|
return b(i, i3, "start index");
|
|
}
|
|
return (i2 < 0 || i2 > i3) ? b(i2, i3, "end index") : a("end index (%s) must not be less than start index (%s)", Integer.valueOf(i2), Integer.valueOf(i));
|
|
}
|
|
|
|
static String a(String str, Object... objArr) {
|
|
int indexOf;
|
|
String valueOf = String.valueOf(str);
|
|
StringBuilder sb = new StringBuilder(valueOf.length() + (objArr.length * 16));
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (i < objArr.length && (indexOf = valueOf.indexOf("%s", i2)) != -1) {
|
|
sb.append((CharSequence) valueOf, i2, indexOf);
|
|
sb.append(objArr[i]);
|
|
i2 = indexOf + 2;
|
|
i++;
|
|
}
|
|
sb.append((CharSequence) valueOf, i2, valueOf.length());
|
|
if (i < objArr.length) {
|
|
sb.append(" [");
|
|
sb.append(objArr[i]);
|
|
for (int i3 = i + 1; i3 < objArr.length; i3++) {
|
|
sb.append(", ");
|
|
sb.append(objArr[i3]);
|
|
}
|
|
sb.append(']');
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|