Assert { public static void notEmpty(final String str, final int errorCode, final Object... params) throws AssertException { if (StringUtils.isEmpty(str)) { throw new AssertException(errorCode, params); } }  static void notNull(final Object obj, final int errorCode, final Object... params); static void isNull(final Object obj, final int errorCode, final Object... params); static void notEmpty(final String str, final int errorCode, final Object... params); static void isEmpty(final String str, final int errorCode, final Object... params); static void notEmpty(final T[] str, final int errorCode, final Object... params); static void isEmpty(final T[] str, final int errorCode, final Object... params); static void notEmpty(final Collection<?> str, final int errorCode, final Object... params); static void isEmpty(final Collection<?> str, final int errorCode, final Object... params); static void notEmpty(final Map<?, ?> str, final int errorCode, final Object... params); static void isEmpty(final Map<?, ?> str, final int errorCode, final Object... params); static void equals(final Object obj1, final Object obj2, final int errorCode, final Object... params); static void notEquals(final Object obj1, final Object obj2, final int errorCode, final Object... params); static void isTrue(final boolean result, final int errorCode, final Object... params); static void isFalse(final boolean result, final int errorCode, final Object... params);  }
@Test public void notEmpty() { String str = "hello world"; Assert.notEmpty(str, ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("str 不是空字符串"); List<String> strList = new ArrayList<>(); strList.add(str); Assert.notEmpty(strList, ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("strList 不是空集合"); String[] strs = new String[] { str }; Assert.notEmpty(strs, ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("strs 不是空数组"); Map<String, String> strMap = new HashMap<>(); strMap.put("a", str); Assert.notEmpty(strMap, ErrorCodeDef.SYSTEM_ERROR_10001); System.out.println("strMap 不是空Map"); }