Assert.java
986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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);
        }
    }
}