cn.hutool.core.lang.Assert.notEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(468)

本文整理了Java中cn.hutool.core.lang.Assert.notEmpty()方法的一些代码示例,展示了Assert.notEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.notEmpty()方法的具体详情如下:
包路径:cn.hutool.core.lang.Assert
类名称:Assert
方法名:notEmpty

Assert.notEmpty介绍

[英]检查给定字符串是否为空,为空抛出 IllegalArgumentException

Assert.notEmpty(name);

[中]检查给定字符串是否为空,为空抛出 IllegalArgumentException

Assert.notEmpty(name);

代码示例

代码示例来源:origin: looly/hutool

/**
 * 断言给定集合非空
 * 
 * <pre class="code">
 * Assert.notEmpty(collection);
 * </pre>
 * 
 * @param <T> 集合元素类型
 * @param collection 被检查的集合
 * @return 被检查集合
 * @throws IllegalArgumentException if the collection is {@code null} or has no elements
 */
public static <T> Collection<T> notEmpty(Collection<T> collection) throws IllegalArgumentException {
  return notEmpty(collection, "[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: looly/hutool

/**
 * 断言给定数组是否包含元素,数组必须不为 {@code null} 且至少包含一个元素
 * 
 * <pre class="code">
 * Assert.notEmpty(array, "The array must have elements");
 * </pre>
 * 
 * @param array 被检查的数组
 * @return 被检查的数组
 * @throws IllegalArgumentException if the object array is {@code null} or has no elements
 */
public static Object[] notEmpty(Object[] array) throws IllegalArgumentException {
  return notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: looly/hutool

/**
 * 断言给定数组是否包含元素,数组必须不为 {@code null} 且至少包含一个元素
 * 
 * <pre class="code">
 * Assert.notEmpty(array, "The array must have elements");
 * </pre>
 * 
 * @param array 被检查的数组
 * @return 被检查的数组
 * @throws IllegalArgumentException if the object array is {@code null} or has no elements
 */
public static Object[] notEmpty(Object[] array) throws IllegalArgumentException {
  return notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: looly/hutool

/**
 * 断言给定Map非空
 * 
 * <pre class="code">
 * Assert.notEmpty(map, "Map must have entries");
 * </pre>
 * 
 * @param <K> Key类型
 * @param <V> Value类型
 * 
 * @param map 被检查的Map
 * @return 被检查的Map
 * @throws IllegalArgumentException if the map is {@code null} or has no entries
 */
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
  return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}

代码示例来源:origin: looly/hutool

/**
 * 检查给定字符串是否为空,为空抛出 {@link IllegalArgumentException}
 * 
 * <pre class="code">
 * Assert.notEmpty(name);
 * </pre>
 * 
 * @param text 被检查字符串
 * @return 被检查的字符串
 * @see StrUtil#isNotEmpty(CharSequence)
 * @throws IllegalArgumentException 被检查字符串为空
 */
public static String notEmpty(String text) throws IllegalArgumentException {
  return notEmpty(text, "[Assertion failed] - this String argument must have length; it must not be null or empty");
}

代码示例来源:origin: looly/hutool

/**
 * 检查给定字符串是否为空,为空抛出 {@link IllegalArgumentException}
 * 
 * <pre class="code">
 * Assert.notEmpty(name);
 * </pre>
 * 
 * @param text 被检查字符串
 * @return 被检查的字符串
 * @see StrUtil#isNotEmpty(CharSequence)
 * @throws IllegalArgumentException 被检查字符串为空
 */
public static String notEmpty(String text) throws IllegalArgumentException {
  return notEmpty(text, "[Assertion failed] - this String argument must have length; it must not be null or empty");
}

代码示例来源:origin: looly/hutool

/**
 * 断言给定集合非空
 * 
 * <pre class="code">
 * Assert.notEmpty(collection);
 * </pre>
 * 
 * @param <T> 集合元素类型
 * @param collection 被检查的集合
 * @return 被检查集合
 * @throws IllegalArgumentException if the collection is {@code null} or has no elements
 */
public static <T> Collection<T> notEmpty(Collection<T> collection) throws IllegalArgumentException {
  return notEmpty(collection, "[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: looly/hutool

/**
 * 断言给定Map非空
 * 
 * <pre class="code">
 * Assert.notEmpty(map, "Map must have entries");
 * </pre>
 * 
 * @param <K> Key类型
 * @param <V> Value类型
 * 
 * @param map 被检查的Map
 * @return 被检查的Map
 * @throws IllegalArgumentException if the map is {@code null} or has no entries
 */
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
  return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 断言给定集合非空
 * 
 * <pre class="code">
 * Assert.notEmpty(collection);
 * </pre>
 * 
 * @param <T> 集合元素类型
 * @param collection 被检查的集合
 * @return 被检查集合
 * @throws IllegalArgumentException if the collection is {@code null} or has no elements
 */
public static <T> Collection<T> notEmpty(Collection<T> collection) throws IllegalArgumentException {
  return notEmpty(collection, "[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 断言给定数组是否包含元素,数组必须不为 {@code null} 且至少包含一个元素
 * 
 * <pre class="code">
 * Assert.notEmpty(array, "The array must have elements");
 * </pre>
 * 
 * @param array 被检查的数组
 * @return 被检查的数组
 * @throws IllegalArgumentException if the object array is {@code null} or has no elements
 */
public static Object[] notEmpty(Object[] array) throws IllegalArgumentException {
  return notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 检查给定字符串是否为空,为空抛出 {@link IllegalArgumentException}
 * 
 * <pre class="code">
 * Assert.notEmpty(name);
 * </pre>
 * 
 * @param text 被检查字符串
 * @return 被检查的字符串
 * @see StrUtil#isNotEmpty(CharSequence)
 * @throws IllegalArgumentException 被检查字符串为空
 */
public static String notEmpty(String text) throws IllegalArgumentException {
  return notEmpty(text, "[Assertion failed] - this String argument must have length; it must not be null or empty");
}

代码示例来源:origin: cn.hutool/hutool-all

/**
 * 断言给定Map非空
 * 
 * <pre class="code">
 * Assert.notEmpty(map, "Map must have entries");
 * </pre>
 * 
 * @param <K> Key类型
 * @param <V> Value类型
 * 
 * @param map 被检查的Map
 * @return 被检查的Map
 * @throws IllegalArgumentException if the map is {@code null} or has no entries
 */
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
  return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}

相关文章