yangys
2024-05-09 014ac34ff2baf657c3236f41fdbf11c9d7d414b4
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
package com.qianwen.smartman.modules.cps.utils;
 
import com.qianwen.core.log.exception.ServiceException;
 
 
public final class ThrowFun {
 
    @FunctionalInterface
    
    public interface ThrowException {
        void throwMessage(String message);
    }
 
    private ThrowFun() {
        throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
    }
 
    public static ThrowException isTrue(boolean flag) {
        return message -> {
            if (flag) {
                throw new ServiceException(message);
            }
        };
    }
}