package cn.iocoder.yudao.framework.common.validation;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;

/**
 * 数据校验
 * @author douya
 * @email douya@gmail.com
 * @date 2017年11月4日 上午11:07:35
 */
public abstract class Assert {

    public static void isBlank(String str, String message) {
        if (StrUtil.isBlank(str)) {
            throw new ServiceException(500, message);
        }
    }

    public static void isBlank(String str, String message, Integer code) {
        if (StrUtil.isBlank(str)) {
            throw new ServiceException(code, message);
        }
    }

    public static void isBlank(Object object, String message, Integer code) {
    	if (object == null || StrUtil.isBlank(String.valueOf(object))) {
            throw new ServiceException(code, message);
        }
    }

    public static void isNull(Object object, String message, Integer code)
    {
        if (object == null || StrUtil.isBlank(String.valueOf(object))) {
            throw new ServiceException(code, message);
        }
    }

    public static void isNull(Object object, String message) {
        if (object == null) {
            throw new ServiceException(500, message);
        }
    }
}
