Asserrt.java
1.08 KB
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
46
47
package com.huaheng.common.exception.base;
import com.huaheng.common.exception.service.ServiceException;
import org.springframework.lang.Nullable;
import java.util.List;
/**
* @ClassName Assert
* @Description TODO
* @Author Administrator
* @Date 2020/5/6 09:51
*/
public abstract class Asserrt {
public Asserrt(){
}
//实体为空,抛异常
public static void notNull(@Nullable Object object, String message){
if(object == null || object == ""){
throw new ServiceException(message);
}
}
//实体为空,抛异常
public static void notListNull(@Nullable List<?> list, String message){
if(list.isEmpty()){
throw new ServiceException(message);
}
}
//修改失败抛异常
public static void update(Integer number,String message){
if(number < 1){
throw new ServiceException(message);
}
}
//false抛异常
public static void isFalse(Boolean result,String message){
if(!result){
throw new ServiceException(message);
}
}
}