zoukankan      html  css  js  c++  java
  • 断言类

    public final class Assert {
    
        private Assert() {
        }
    
        public static void notNull(Object object) {
            if (object == null) {
                throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR_IS_NULL);
            }
        }
    
        public static void notNull(Object... object) {
            for (Object obj : object) {
                if (obj == null) {
                    throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR_IS_NULL);
                }
            }
        }
    
        public static void isPositive(Long number) {
            if (number == null || number <= 0) {
                throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR);
            }
        }
    
        public static void isPositive(Long... number) {
            for (Long num : number) {
                if (num == null || num <= 0) {
                    throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR);
                }
            }
        }
    
        public static void isPositive(Integer number) {
            if (number == null || number <= 0) {
                throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR);
            }
        }
    
        public static void isPositive(Integer... number) {
            for (Integer num : number) {
                if (num == null || num <= 0) {
                    throw new ApiRuntimeException(ErrorCode.SYSTEM_PARAM_ERROR);
                }
            }
        }
    
        public static void notEmpty(String str, ErrorCode errorCode) {
            if (StringUtils.isEmpty(str)) {
                throw new ApiRuntimeException(errorCode);
            }
        }
    
        public static void notBlank(String str, ErrorCode errorCode) {
            if (StringUtils.isBlank(str)) {
                throw new ApiRuntimeException(errorCode);
            }
        }
    
        public static void isTrue(boolean condition, ErrorCode errorCode) {
            if (!condition) {
                throw new ApiRuntimeException(errorCode);
            }
        }
    }

    断言类,用来在业务类之前判断参数。

  • 相关阅读:
    Fixed数据类型
    unity3d游戏物体跟着鼠标方向移动
    unity gl 画线
    Unity3D研究院之游戏对象的访问绘制线与绘制面详解(十七)
    像素填充率,纹理填充率,显存带宽
    GPU渲染管线与shader
    Unity协程(Coroutine)原理深入剖析
    C#基本线程同步
    C#多线程编程
    详解C#中的反射
  • 原文地址:https://www.cnblogs.com/television/p/9394429.html
Copyright © 2011-2022 走看看