ObjectUtils.java 643 B

1234567891011121314151617181920212223242526272829303132
  1. package com.ymwk.icvp.signature.utils;
  2. import java.lang.reflect.Array;
  3. import java.util.Collection;
  4. import java.util.Map;
  5. public class ObjectUtils {
  6. public static boolean isEmpty(Object obj) {
  7. if (obj == null) {
  8. return true;
  9. }
  10. if (obj instanceof CharSequence) {
  11. return ((CharSequence) obj).length() == 0;
  12. }
  13. if (obj.getClass().isArray()) {
  14. return Array.getLength(obj) == 0;
  15. }
  16. if (obj instanceof Collection) {
  17. return ((Collection) obj).isEmpty();
  18. }
  19. if (obj instanceof Map) {
  20. return ((Map) obj).isEmpty();
  21. }
  22. return false;
  23. }
  24. public static boolean isNotEmpty(Object obj) {
  25. return !isEmpty(obj);
  26. }
  27. }