liujie
2023-08-04 1f9d05fd255fbd21356dad37527c7d33fda4fb8b
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
package com.dsh.course.util;
 
import cn.mb.cloud.common.core.exception.BusinessException;
import org.springframework.util.StringUtils;
 
import java.util.Objects;
 
/**
 * 判断字符串不能为空和null,以及号码格式效验,
 * 否则则抛出异常信息
 */
public class StringUtil {
    private StringUtil() {
    }
 
    public static void checkNull(String str, String message) throws BusinessException {
        if (!StringUtils.hasLength(str)) {
            throw new BusinessException(message);
        }
    }
 
    public static void checkFormat(String str, String message) throws BusinessException {
        if (!str.matches("^1[2|3|4|5|6|7|8|9][0-9]{9}$")) {
            throw new BusinessException(message);
        }
    }
 
    public static boolean isOneEmpty(Object... os) {
        for (Object o : os) {
            if (Objects.isNull(o)) {
                return true;
            }
        }
        return false;
    }
}