Java 数据类型非空与非零判断工具类

public class VerificationUtil {
    //判断 Integer类型数据 非零
    public static boolean notZero(Integer num) {
        if (num == null) {
            return false;
        } else return num != 0;
    }
    //判断 Integer 类型数据 零
    public static boolean zero(Integer num) {
        if (num == null) {
            return true;
        } else return num == 0;
    }
    //判断 Integer类型数据 非零
    public static boolean notZero(Long num) {
        if (num == null) {
            return false;
        } else return num != 0;
    }
    //判断 Long类型数据 零
    public static boolean zero(Long num) {
        if (num == null) {
            return true;
        } else return num == 0;
    }
    //判断 Double类型数据 非零
    public static boolean notZero(Double num) {
        if (num == null) {
            return false;
        } else return num != 0;
    }
    //判断 Double类型数据 零
    public static boolean zero(Double num) {
        if (num == null) {
            return true;
        } else return num == 0;
    }
    //判断 Integer 类型数据 非空
    public static boolean isNotNull(Integer num) {
        return num != null;
    }
    //判断 Integer 类型数据 非空
    public static boolean isNull(Integer num) {
        return num == null;
    }
    //判断 Long 类型数据 非空
    public static boolean isNotNull(Long num) {
        return num != null;
    }
    //判断 Long 类型数据 空
    public static boolean isNull(Long num) {
        return num == null;
    }
    //判断 Double 类型数据 非空
    public static boolean isNotNull(Double num) {
        return num != null;
    }
    //判断 Double 类型数据 空
    public static boolean isNull(Double num) {
        return num == null;
    }
    //判断 Date 类型数据 非空
    public static boolean isNotNull(Date d) {
        return d != null;
    }
    //判断 Date 类型数据 空
    public static boolean isNull(Date d) {
        return d == null;
    }

}

你可能感兴趣的:(java)