/** * Assert that a collection has elements; that is, it must not be <code>null</code> and must have * at least one element. * * <pre class="code"> * Assert.notEmpty(collection, "Collection must have elements"); * </pre> * * @param collection the collection to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the collection is <code>null</code> or has no elements */ public static void notEmpty(Collection collection, String message) { if (DataUtil.isNullOrEmpty(collection)) { throw new IllegalArgumentException(message); } }
/** * Assert that a Map has entries; that is, it must not be <code>null</code> and must have at least * one entry. * * <pre class="code"> * Assert.notEmpty(map, "Map must have entries"); * </pre> * * @param map the map to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the map is <code>null</code> or has no entries */ public static void notEmpty(Map map, String message) { if (DataUtil.isNullOrEmpty(map)) { throw new IllegalArgumentException(message); } }
/** * Assert that an array has elements; that is, it must not be <code>null</code> and must have at * least one element. * * <pre class="code"> * Assert.notEmpty(array, "The array must have elements"); * </pre> * * @param array the array to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the object array is <code>null</code> or has no elements */ public static void notEmpty(Object[] array, String message) { if (DataUtil.isNullOrEmpty(array)) { throw new IllegalArgumentException(message); } }