All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.niuable.utils.EmptyKit Maven / Gradle / Ivy

package cn.niuable.utils;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 常用工具类
 * 
 * @author 王维
 * 
 *         
 * www.51xlxy.com
 * 2018-05-23
 * [email protected]
 * All rights Reserved, Designed By WangWei
 *         
*/ public class EmptyKit { /** * 基本数据判断是否为空 * * @param o 被判断对象 * @param 泛型 * @return 是否为空 */ public static boolean isEmpty(T o) { if (o == null) { return true; } final String empty0 = "0"; if (o instanceof String) { return "".equals(o.toString().trim()); } else if (o instanceof List) { return ((List) o).size() == 0; } else if (o instanceof Map) { return ((Map) o).size() == 0; } else if (o instanceof Set) { return ((Set) o).size() == 0; } else if (o instanceof Object[]) { return ((Object[]) o).length == 0; } else if (o instanceof int[]) { return ((int[]) o).length == 0; } else if (o instanceof long[]) { return ((long[]) o).length == 0; } else if (o instanceof Integer) { String lTrim = o.toString().trim(); return empty0.equals(lTrim); } else if (o instanceof Long) { String lTrim = o.toString().trim(); return empty0.equals(lTrim); } return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy