ObjectUtil { public static boolean isEmpty(Object object) { if (object == null) { return true; } if (object instanceof String) { return StringUtil.isEmpty(object.toString()); } if (object.getClass().isArray()) { return Array.getLength(object) == 0; } return false; }  static T defaultIfNull(T object, S defaultValue); static boolean isEquals(Object object1, Object object2); static int hashCode(Object object); static int identityHashCode(Object object); static String identityToString(Object object); static String identityToString(Object object, String nullStr); static A appendIdentityToString(A buffer, Object object); static String toString(Object object); static String toString(Object object, String nullStr); static boolean isSameType(Object object1, Object object2); static boolean isEmpty(Object object); static boolean isNotEmpty(Object object); static boolean isNull(Object object); static boolean isNotNull(Object object); static boolean isAllNull(Object...objects); static boolean isAnyNull(Object...objects); static int nullNum(Object...objects); static StringBuilder appendIdentityToString(StringBuilder builder, Object object); static StringBuffer appendIdentityToString(StringBuffer buffer, Object object); static Object clone(Object array); static final String SERIAL_VERSION_UID; }
@Test public void isEmpty() { assertTrue(ObjectUtil.isEmpty(null)); assertFalse(ObjectUtil.isEmpty(0)); assertTrue(ObjectUtil.isEmpty("")); assertFalse(ObjectUtil.isEmpty(" ")); assertFalse(ObjectUtil.isEmpty("bob")); assertFalse(ObjectUtil.isEmpty(" bob ")); assertFalse(ObjectUtil.isEmpty("\u3000")); assertFalse(ObjectUtil.isEmpty("\r\n")); assertTrue(ObjectUtil.isEmpty(new Object[0])); assertTrue(ObjectUtil.isEmpty(new int[0])); assertFalse(ObjectUtil.isEmpty(new int[] { 1, 2 })); }