package com.ssyf.common.core.util;

/**
 * 断言工具
 * @author huwei
 * @date 2022/7/19 20:45
 */
public class AssertUtil {

    public static final void isTrue(boolean state , String message){
        isTrue(state ,new RuntimeException(message));
    }

    public static final void isTrue(boolean state , RuntimeException exception){
        if(!state){
            throw exception;
        }
    }

    public static final void isFalse(boolean state , String message){
        isTrue(!state ,message);
    }

    public static final void isFalse(boolean state , RuntimeException exception){
        isTrue(!state ,exception);
    }

    public static final void isNull(Object object , String message){
        isTrue(object == null ,message);
    }

    public static final void isNull(Object object , RuntimeException exception){
        isTrue(object == null ,exception);
    }

    public static final void isNotNull(Object object , String message){
        isTrue(object != null ,message);
    }

    public static final void isNotNull(Object object , RuntimeException exception){
        isTrue(object != null ,exception);
    }

}
