Checker { public static <T> boolean isNullOrEmpty(T[] array) { return array == null || array.length == 0; } private  Checker(); static boolean isNullOrEmpty(T[] array); static boolean isNullOrEmpty(Collection<?> collection); static boolean isNullOrEmpty(Map<?, ?> map); static boolean isNullOrEmpty(String value); static boolean isBlank(String value); @Deprecated static boolean equals(Object a, Object b);  }
@Test public void testIsNullOrEmptyArray() { assertTrue(Checker.isNullOrEmpty((Object[]) null)); assertTrue(Checker.isNullOrEmpty(new Object[] {})); assertFalse(Checker.isNullOrEmpty(new String[] { null })); assertFalse(Checker.isNullOrEmpty(new String[] { "" })); assertFalse(Checker.isNullOrEmpty(new String[] { "Test1" })); assertFalse(Checker.isNullOrEmpty(new String[] { "Test1", "Test2" })); }
@Test public void testIsNullOrEmptyCollection() { assertTrue(Checker.isNullOrEmpty((List<?>) null)); assertTrue(Checker.isNullOrEmpty(new ArrayList<>())); assertTrue(Checker.isNullOrEmpty(new HashSet<>())); assertTrue(Checker.isNullOrEmpty(new ArrayList<>(1))); assertFalse(Checker.isNullOrEmpty(Arrays.asList(""))); assertFalse(Checker.isNullOrEmpty(Arrays.asList("Test1"))); assertFalse(Checker.isNullOrEmpty(Arrays.asList(1, 2))); }
@Test public void testIsNullOrEmptyMap() { assertTrue(Checker.isNullOrEmpty((Map<?, ?>) null)); assertTrue(Checker.isNullOrEmpty(new HashMap<Object, Void>())); Map<String, Integer> m = new HashMap<>(2); assertTrue(Checker.isNullOrEmpty(m)); m.put(null, null); assertFalse(Checker.isNullOrEmpty(m)); m.remove(null); assertTrue(Checker.isNullOrEmpty(m)); m.put("123", 456); assertFalse(Checker.isNullOrEmpty(m)); }
@Test public void testIsNullOrEmptyString() { assertTrue(Checker.isNullOrEmpty((String) null)); assertTrue(Checker.isNullOrEmpty("")); assertFalse(Checker.isNullOrEmpty(" ")); assertFalse(Checker.isNullOrEmpty("\\t\\n \\r\\l")); assertFalse(Checker.isNullOrEmpty("test")); }