提交 | 用户 | 时间
|
8286c6
|
1 |
package cn.stylefeng.guns.gen.core.util; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.gen.modular.model.GenSessionFieldConfigs; |
|
4 |
|
|
5 |
/** |
|
6 |
* 临时变量存放 |
|
7 |
* |
|
8 |
* @author fengshuonan |
|
9 |
* @date 2019-05-06-18:33 |
|
10 |
*/ |
|
11 |
public class FieldsConfigHolder { |
|
12 |
|
|
13 |
private static ThreadLocal<GenSessionFieldConfigs> threadLocal = new ThreadLocal<>(); |
|
14 |
|
|
15 |
public static void put(GenSessionFieldConfigs value) { |
|
16 |
threadLocal.set(value); |
|
17 |
} |
|
18 |
|
|
19 |
public static GenSessionFieldConfigs get() { |
|
20 |
GenSessionFieldConfigs genSessionFieldConfigs = threadLocal.get(); |
|
21 |
|
|
22 |
//threadlocal没有的话new一个 |
|
23 |
if (genSessionFieldConfigs == null) { |
|
24 |
return new GenSessionFieldConfigs(); |
|
25 |
} else { |
|
26 |
return genSessionFieldConfigs; |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
public static void remove() { |
|
31 |
threadLocal.remove(); |
|
32 |
} |
|
33 |
} |