org.enodeframework.common.utilities.Ensure Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enode Show documentation
Show all versions of enode Show documentation
The enodeframework core implementation.
package org.enodeframework.common.utilities;
import com.google.common.base.Strings;
/**
* @author [email protected]
*/
public class Ensure {
public static void notNull(T argument, String argumentName) {
if (argument == null) {
throw new IllegalArgumentException(String.format("%s should not be null.", argumentName));
}
}
public static void notNullOrEmpty(String argument, String argumentName) {
if (Strings.isNullOrEmpty(argument)) {
throw new IllegalArgumentException(String.format("%s should not be null or empty.", argumentName));
}
}
public static void equal(int expected, int actual, String argumentName) {
if (expected != actual) {
throw new IllegalArgumentException(String.format("%s expected value: %d, actual value: %d", argumentName, expected, actual));
}
}
public static void equal(long expected, long actual, String argumentName) {
if (expected != actual) {
throw new IllegalArgumentException(String.format("%s expected value: %d, actual value: %d", argumentName, expected, actual));
}
}
public static void equal(boolean expected, boolean actual, String argumentName) {
if (expected != actual) {
throw new IllegalArgumentException(String.format("%s expected value: %d, actual value: %d", argumentName, expected, actual));
}
}
}