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 java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* object util class
*
* @author sunhao([email protected])
* @createtime 2012-6-26 上午09:44:13
*/
public class ObjectUtils extends org.apache.commons.lang.ObjectUtils {
/**
* 默认方法名前缀
*/
private static final String DEFAULT_METHOD_PREFIX = "get";
private ObjectUtils() {
super();
}
/**
* 判断是否为空
*
* @param obj
* @return
*/
public static boolean isEmpty(Object obj) throws Exception {
return obj == null;
}
/**
* 判断是否为非空
*
* @param obj
* @return
*/
public static boolean isNotEmpty(Object obj) throws Exception {
return !isEmpty(obj);
}
/**
* 获取object的class
*
* @param obj
* @return
* @throws Exception
*/
public static Class> getClazz(Object obj) throws Exception {
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