1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.sooka.common.utils;
- import java.util.Collection;
- import java.util.Map;
- /**
- * Description:cms 工具类
- *
- *
- * @create 2017-05-15
- **/
- public class CmsUtil {
- /* 判断对象是否为空 */
- public static boolean isNullOrEmpty(Object obj) {
- if (obj == null) {
- return true;
- }
- if (obj instanceof CharSequence) {
- return ((CharSequence) obj).length() == 0;
- }
- if (obj instanceof Collection) {
- return ((Collection<?>) obj).isEmpty();
- }
- if (obj instanceof Map) {
- return ((Map<?, ?>) obj).isEmpty();
- }
- if (obj instanceof Object[]) {
- Object[] object = (Object[]) obj;
- if (object.length == 0) {
- return true;
- }
- boolean empty = true;
- for (int i = 0; i < object.length; i++) {
- if (!isNullOrEmpty(object[i])) {
- empty = false;
- break;
- }
- }
- return empty;
- }
- return false;
- }
- }
|