io.github.saoxuequ.http.request.utils.Preconditions Maven / Gradle / Ivy
package io.github.saoxuequ.http.request.utils;
public class Preconditions {
private Preconditions() {
}
public static void checkState(boolean expression, String message) {
if (!expression) {
throw new IllegalStateException(message);
}
}
public static void checkState(boolean expression) {
if (!expression) {
throw new IllegalStateException();
}
}
public static void checkNotNull(Object obj) {
if (obj == null) {
throw new NullPointerException();
}
}
public static void checkNotNull(Object obj, String errorMessage) {
if (obj == null) {
throw new NullPointerException(errorMessage);
}
}
public static void checkArgument(boolean expression) {
if (!expression) {
throw new IllegalArgumentException();
}
}
public static void checkArgument(boolean expression, String errorMessage) {
if (!expression) {
throw new IllegalArgumentException(errorMessage);
}
}
}