CommonUtils { public static boolean isNotEmpty(Collection collection) { return collection != null && !collection.isEmpty(); }  static V putToConcurrentMap(ConcurrentMap<K, V> map, K key, V value); static boolean isTrue(String b); static boolean isTrue(Boolean b); static boolean isFalse(Boolean b); static boolean isFalse(String b); static boolean isEmpty(Collection collection); static boolean isNotEmpty(Collection collection); static boolean isEmpty(Map map); static boolean isNotEmpty(Map map); static boolean isEmpty(Object[] array); static boolean isNotEmpty(Object[] array); static T parseNum(T num, T defaultInt); static int parseInt(String num, int defaultInt); static long parseLong(String num, long defaultLong); static boolean parseBoolean(String bool, boolean defaultInt); static int[] parseInts(String nums, String sperator); static boolean listEquals(List<T> left, List<T> right); static String join(Collection collection, String separator);  }
@Test public void testIsNotEmpty() { List list1 = null; List list2 = new ArrayList(); List list3 = new ArrayList(); list3.add(1); Assert.assertTrue(CommonUtils.isEmpty(list1)); Assert.assertTrue(CommonUtils.isEmpty(list2)); Assert.assertFalse(CommonUtils.isEmpty(list3)); Assert.assertFalse(CommonUtils.isNotEmpty(list1)); Assert.assertFalse(CommonUtils.isNotEmpty(list2)); Assert.assertTrue(CommonUtils.isNotEmpty(list3)); Set set1 = null; Set set2 = new HashSet(); Set set3 = new HashSet(); set3.add(1); Assert.assertTrue(CommonUtils.isEmpty(set1)); Assert.assertTrue(CommonUtils.isEmpty(set2)); Assert.assertFalse(CommonUtils.isEmpty(set3)); Assert.assertFalse(CommonUtils.isNotEmpty(set1)); Assert.assertFalse(CommonUtils.isNotEmpty(set2)); Assert.assertTrue(CommonUtils.isNotEmpty(set3)); HashMap map1 = null; HashMap map2 = new HashMap(); HashMap map3 = new HashMap(); map3.put(1, 1); Assert.assertTrue(CommonUtils.isEmpty(map1)); Assert.assertTrue(CommonUtils.isEmpty(map2)); Assert.assertFalse(CommonUtils.isEmpty(map3)); Assert.assertFalse(CommonUtils.isNotEmpty(map1)); Assert.assertFalse(CommonUtils.isNotEmpty(map2)); Assert.assertTrue(CommonUtils.isNotEmpty(map3)); String[] array1 = null; String[] array2 = new String[0]; String[] array3 = new String[] { "11" }; Assert.assertTrue(CommonUtils.isEmpty(array1)); Assert.assertTrue(CommonUtils.isEmpty(array2)); Assert.assertFalse(CommonUtils.isEmpty(array3)); Assert.assertFalse(CommonUtils.isNotEmpty(array1)); Assert.assertFalse(CommonUtils.isNotEmpty(array2)); Assert.assertTrue(CommonUtils.isNotEmpty(array3)); }