lodsve.core.utils.ObjectUtils Maven / Gradle / Ivy
/*
* Copyright (C) 2018 Sun.Hao
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package lodsve.core.utils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.util.Assert;
import java.lang.reflect.Field;
import java.util.*;
/**
* object util class
*
* @author sunhao([email protected])
* @date 2012-6-26 上午09:44:13
*/
public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
private ObjectUtils() {
super();
}
/**
* 判断是否为空
*
* @param obj
* @return
*/
public static boolean isEmpty(Object obj) {
return obj == null;
}
/**
* 判断是否为非空
*
* @param obj
* @return
*/
public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}
/**
* 获取object的class
*
* @param obj
* @return
*/
public static Class> getType(Object obj) {
return isEmpty(obj) ? null : obj.getClass();
}
/**
* 第一个object数组是否包含第二个object数组
*
* @param obj1 包含的数组 为空返回false
* @param obj2 被包含的数组 为空返回false
* @return
*/
public static boolean contain(Object[] obj1, Object[] obj2) {
if (obj1 == null || obj1.length < 1) {
return false;
}
if (obj2 == null || obj2.length < 1) {
return false;
}
List