package io.netty.util.internal;

/* JADX INFO: loaded from: classes.dex */
public final class ObjectUtil {
    private ObjectUtil() {
    }

    public static <T> T[] checkNonEmpty(T[] tArr, String str) {
        checkNotNull(tArr, str);
        checkPositive(tArr.length, str + ".length");
        return tArr;
    }

    public static <T> T checkNotNull(T t, String str) {
        if (t != null) {
            return t;
        }
        throw new NullPointerException(str);
    }

    public static int checkPositive(int i2, String str) {
        if (i2 > 0) {
            return i2;
        }
        throw new IllegalArgumentException(str + ": " + i2 + " (expected: > 0)");
    }

    public static int checkPositiveOrZero(int i2, String str) {
        if (i2 >= 0) {
            return i2;
        }
        throw new IllegalArgumentException(str + ": " + i2 + " (expected: >= 0)");
    }

    public static int intValue(Integer num, int i2) {
        return num != null ? num.intValue() : i2;
    }

    public static long longValue(Long l, long j2) {
        return l != null ? l.longValue() : j2;
    }

    public static long checkPositive(long j2, String str) {
        if (j2 > 0) {
            return j2;
        }
        throw new IllegalArgumentException(str + ": " + j2 + " (expected: > 0)");
    }
}
