26 lines
840 B
Java
26 lines
840 B
Java
package net.locusworks.common.utils;
|
|
|
|
public class Checks {
|
|
|
|
public static void checkArguments(boolean expression, String error) {
|
|
checkArguments(expression, "%s", error);
|
|
}
|
|
|
|
public static void checkArguments(boolean expression, String errorFmt, Object... args) {
|
|
if (!expression) throw new IllegalArgumentException(String.format(errorFmt, args));
|
|
}
|
|
|
|
public static void checkState(boolean expression, String error) {
|
|
checkState(expression, "%s", error);
|
|
}
|
|
|
|
public static void checkState(boolean expression, String errorFmt, Object... args) {
|
|
if (!expression) throw new IllegalStateException(String.format(errorFmt, args));
|
|
}
|
|
|
|
public static void checkNotNull(Object item, String error) {
|
|
if (item == null) throw new IllegalAccessError("Provided item is null");
|
|
}
|
|
|
|
}
|