public class EmptyUtil {
/**
* 判断对象是否不为空
*/
public static <T> boolean isNotEmpty(Object value) {
if (null != value) {
if (EmptyUtil.isEmpty(value.toString())) {
return false;
}
return true;
}
return false;
}
/**
* 判断Object是否不为空,先判断是否不为null,为null返回false;不为null 继续判断toString()是否不为空
*
* */
public static <T> boolean isEmpty(Object value) {
if (null == value) {
return true;
} else if (EmptyUtil.isEmpty(value.toString())) {
return true;
}
return false;
}
/**
* 判断字符串是否不为空
*
* */
public static boolean isNotEmpty(String datas) {
if (null != datas) {
if ("".equals(datas.trim())) {
return false;
} else if (StringUtils.isBlank(datas)) {
return false;
}
return true;
}
return false;
}
/**
* 判断字符串是否为空
*
* */
public static boolean isEmpty(String datas) {
if (null == datas) {
return true;
} else if ("".equals(datas.trim())) {
return true;
} else if (StringUtils.isBlank(datas)) {
return true;
}
return false;
}
/**
* 判断集合是否不为空
*/
public static <T> boolean isNotEmpty(List<T> lists) {
if (null != lists) {
if (lists.isEmpty()) {
return false;
}
return true;
}
return false;
}
/**
* 判断集合是否为空
*/
public static <T> boolean isEmpty(List<T> lists) {
if (null == lists) {
return true;
} else if (lists.isEmpty()) {
return true;
}
return false;
}
}
判断是否为空的一些方法
最新推荐文章于 2024-02-27 16:10:07 发布