java空值判断工具

package 


import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;

/**
 * 
 *@类名称	: BlankUtil.java
 *@类描述	:空对象、空字符串判断工具类
 *@创建人	:kwy
 *@创建时间	:2018年8月14日 09:42:35
 *@修改人	:
 *@修改时间	:
 *@版本号	:v1.0
 */
public abstract class BlankUtils {

	/**
	 * 
	 * @param str
	 * @return
	 * @description:   判断字符串是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:42:54
	 */
	public static boolean isBlank(final String str) {
		return str == null || str.trim().isEmpty();
	}
	
	
	
	public static boolean isBlank(final BigDecimal str) {
		return (str == null);
	}
	
	
	
	/**
	 * 
	 * 方法说明:判断数组是否为空<p>
	 * 作者:kwy
	 * 时间:2018年8月14日 09:43:55
	 * @param arr Object[]
	 * @return boolean
	 */
	public static boolean isBlank(final Object... arr) {
		return arr == null || arr.length == 0;
	}
	

	/**
	 * 
	 * @param cha
	 * @return
	 * @description:   判断字符是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:44:17
	 */
	public static boolean isBlank(final Character cha) {
		return (cha == null) || cha.equals(' ');
	}

	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断对象是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:44:27
	 */
	public static boolean isBlank(final Object obj) {
		return !(obj != null &&!"null".equalsIgnoreCase(String.valueOf(obj)));
	}
	
	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断对象是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:44:44
	 */
	public static boolean isBlank(final Properties properties) {
		return (properties == null||properties.isEmpty());
	}
	


	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断Collectionj是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:44:53
	 */
	public static <E> boolean isBlank(final Collection<E> obj) {
		return obj == null || obj.isEmpty();
	}

	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断AbstractList是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:45:00
	 */
	public static <E> boolean isBlank(final Vector<E> obj) {
		return (obj == null) || (obj.size() <= 0);
	}
	
	
	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断Set是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:45:08
	 */
	public static <E> boolean isBlank(final Set<E> obj) {
		return (obj == null) || (obj.size() <= 0);
	}

	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断Serializable是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:45:16
	 */
	public static boolean isBlank(final Serializable obj) {
		return obj == null;
	}

	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断Map是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:45:24
	 */
	public static <K,V> boolean isBlank(final Hashtable<K,V> obj) {
		return (obj == null) || obj.isEmpty();
	}
	
	/**
	 * 
	 * @param obj
	 * @return
	 * @description:   判断Map是否为空
	 * @return: boolean
	 * @method: isBlank
	 * @author: kwy
	 * @version: 2018年8月14日 09:45:31
	 */
	public static <K,V> boolean isBlank(final Map<K,V> obj) {
		return obj == null || obj.isEmpty();
	}
	

}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值