Assert.java 986 Bytes
package com.huaheng.common.exception.service;

import org.springframework.lang.Nullable;

import java.util.List;

/**
 * @ClassName Assert
 * @Description TODO
 * @Author Administrator
 * @Date 2020/5/314:51
 */
public abstract class Assert {

    public Assert(){

    }

    public static void notNull(@Nullable Object object,String message){
        if(object == null){
            throw new ServiceException(message);
        }
    }

    //实体为空,抛异常
    public static void notListNull(@Nullable List<?> list, String message){
        if(list.isEmpty()){
            throw new ServiceException(message);
        }
    }

    //修改失败抛异常
    public static void update(Boolean bool,String message){
        if(!bool ){
            throw new ServiceException(message);
        }
    }

    //false抛异常
    public static void isFalse(Boolean result,String message){
        if(!result){
            throw new ServiceException(message);
        }
    }
}