• 非空验证(源代码Java版)


    import java.util.Map;
    
    /**
     *  非空验证工具类
     */
    public class UntilEmpty {
    
        /**
         * @see: 验证string类型的是否为空
         */
        public static boolean isNullorEmpty(String str) {
            //为了执行忽略大小写的比较,可以调用equalsIgnoreCase( )方法。当比较两个字符串时,它会认为A-Z和a-z是一样的。
            if ((str == null) || ("".equals(str)) || ("null".equalsIgnoreCase(str)) || ("undefined".equalsIgnoreCase(str))) {
                return true;
            }
            return false;
        }
    
        /**
         * @see: 验证实体是否为空
         */
        public static <T> boolean isNullorEmpty(T entity) {
            if (entity == null) {
                return true;
            } else {
                return false;
            }
        }
    
        /**
         * @see: 验证StringBuffer类型的是否为空
         */
        public static boolean isNullorEmpty(StringBuffer str) {
            if (str == null ||"".equals(str.toString())  || str.length() == 0) {
                return true;
            } else {
                return false;
            }
        }
    
        /**
         * @see: 验证Map类型的是否为空
         */
        public static boolean isNullorEmpty(Map map) {
            if ((map == null) || (map.size() == 0)) {
                return true;
            }
            return false;
        }
    
     
    
        /**
         * @see: 验证Object数组类型的是否为空
         */
        public static boolean isNullorEmpty(Object[] obj) {
            if ((obj == null) || (obj.length == 0)) {
                return true;
            }
            return false;
        }
    
        /**
         * @see: 验证Long类型的是否为空
         */
        public static boolean isNullorEmpty(Long longTime) {
            if ((longTime == null) || (longTime.longValue() <= 0L)) {
                return true;
            }
            return false;
        }
    
        /**
         * @see: 验证String数组类型的是否为空
         */
        public static boolean isNullorEmpty(String[] str) {
            if ((str == null) || (str.length == 0)) {
                return true;
            }
            return false;
        }
    }
    梦想还是要有的,万一实现了呢!
  • 相关阅读:
    zoj 2913 Bus Pass
    poj 2478 Farey Sequence
    zoj 1649 Rescue
    秒懂JavaScript HTML DOM 元素 (节点)
    看了就会的JS(JavaScript)addEventListener()
    秒懂javascript的原型(prototype)对象、原型链的前世今生
    构造函数用途及优缺点
    一文读懂 js(JavaScript)中call() 和 apply() 的用法
    js (JavaScript)函数声明的几种形式及用法
    JavaScript 代码规范
  • 原文地址:https://www.cnblogs.com/jianfeijiang/p/6140278.html
Copyright © 2020-2023  润新知