/** * Checks value is not null * * @param argument * @param message * @param params * @throws IllegalStateException */ public static void notNull(final Object argument, final String message, final Object... params) { if (argument == null) { throw new IllegalStateException(Args.format(message, params)); } }
/** * Check if argument is false * * @param argument * @param msg * @param params * @return argument */ public static boolean isFalse(final boolean argument, final String msg, final Object... params) { if (argument == true) { throw new IllegalArgumentException(format(msg, params)); } return argument; }
/** * Check if argument is true * * @param argument * @param msg * @param params * @return argument */ public static boolean isTrue(final boolean argument, final String msg, final Object... params) { if (argument == false) { throw new IllegalArgumentException(format(msg, params)); } return argument; }
/** * * Checks argument is not null or empty * * @param collection * @param message * @param params * @return the {code collection} * @throws IllegalArgumentException * if the passed collection is either null or empty */ public static <T extends Collection<?>> T notEmpty(final T collection, final String message, final Object... params) { if (collection == null || collection.isEmpty()) { throw new IllegalArgumentException(Args.format(message, params)); } return collection; }
/** * Checks argument is not empty (not null and has a non-whitespace character) * * @param argument * @param message * @param params * @throws IllegalStateException */ public static void notEmpty(final String argument, final String message, final Object... params) { if (Strings.isEmpty(argument)) { throw new IllegalStateException(Args.format(message, params)); } }