CmsUtil.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.sooka.common.utils;
  2. import java.util.Collection;
  3. import java.util.Map;
  4. /**
  5. * Description:cms 工具类
  6. *
  7. *
  8. * @create 2017-05-15
  9. **/
  10. public class CmsUtil {
  11. /* 判断对象是否为空 */
  12. public static boolean isNullOrEmpty(Object obj) {
  13. if (obj == null) {
  14. return true;
  15. }
  16. if (obj instanceof CharSequence) {
  17. return ((CharSequence) obj).length() == 0;
  18. }
  19. if (obj instanceof Collection) {
  20. return ((Collection<?>) obj).isEmpty();
  21. }
  22. if (obj instanceof Map) {
  23. return ((Map<?, ?>) obj).isEmpty();
  24. }
  25. if (obj instanceof Object[]) {
  26. Object[] object = (Object[]) obj;
  27. if (object.length == 0) {
  28. return true;
  29. }
  30. boolean empty = true;
  31. for (int i = 0; i < object.length; i++) {
  32. if (!isNullOrEmpty(object[i])) {
  33. empty = false;
  34. break;
  35. }
  36. }
  37. return empty;
  38. }
  39. return false;
  40. }
  41. }