zoukankan      html  css  js  c++  java
  • 非空验证(源代码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;
        }
    }
    梦想还是要有的,万一实现了呢!
  • 相关阅读:
    C盘格式化
    电脑显示器有波纹抖动怎么办
    磁盘碎片
    如何把Excel另存为XML格式文件(快速转换)
    题目1551:切蛋糕
    题目1552:座位问题
    题目1550:分糖果
    题目1493:公约数
    题目1544:数字序列区间最小值
    RMQ (Range Minimum/Maximum Query)算法
  • 原文地址:https://www.cnblogs.com/jianfeijiang/p/6140278.html
Copyright © 2011-2022 走看看