package com.yn.bftl.thirdparty.common.util;

import com.yn.bftl.common.common.exception.YnceError;
import com.yn.bftl.common.common.exception.YnceErrorCode;
import com.yn.bftl.thirdparty.common.exception.YnceErrorException;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.lang.Nullable;

/**
 * Assertion utility class that assists in validating arguments.
 *
 * @author chendehuihuo
 * @date 2022/7/28 10:59
 */
public class AssertUtil {

    public static void notNull(@Nullable Object object, String message) {
        if (object == null) {
            throw new YnceErrorException(YnceError.YNCE_100002.getStatus(), message);
        }
    }

    public static void notNull(@Nullable Object object, YnceErrorCode ynceErrorCode) {
        if (object == null) {
            throw new YnceErrorException(ynceErrorCode);
        }
    }

    public static void notEmpty(@Nullable Object object, String message) {
        if (ObjectUtils.isEmpty(object)) {
            throw new YnceErrorException(YnceError.YNCE_100002.getStatus(), message);
        }
    }
}
