All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aluka.nirvana.framework.exception.utils.ArgumentUtil Maven / Gradle / Ivy

The newest version!
package com.aluka.nirvana.framework.exception.utils;

import com.aluka.nirvana.framework.exception.assortment.ArgumentException;
import com.aluka.nirvana.framework.exception.constant.ArgumentErrors;

/**
 * 校验参数基本工具
 * @author gongli
 * @since 2019/12/25
 */
public class ArgumentUtil {
    private ArgumentUtil() {
    }

    public static void checkArgument(boolean expression, String message) {
        if (!expression) {
            ArgumentException e = new ArgumentException(ArgumentErrors.ARGUMENT_ERROR);
            e.setAdditionalMessage(message);
            throw e;
        }
    }

    public static void checkNull(Object arg, String message) {
        if (arg == null) {
            ArgumentException e = new ArgumentException(ArgumentErrors.NOT_NULL);
            e.setAdditionalMessage(message);
            throw e;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy