使用单例枚举保证流水号工具类为全局单例
This commit is contained in:
parent
b27ebec5ba
commit
589f03a103
|
@ -25,6 +25,23 @@ public class CodeGenerationUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用单例枚举保证全局单例
|
||||||
|
*/
|
||||||
|
enum CodeGenerationUtilsEnum {
|
||||||
|
INSTANCE;
|
||||||
|
private CodeGenerationUtils codeGenerationUtils;
|
||||||
|
|
||||||
|
CodeGenerationUtilsEnum() {
|
||||||
|
codeGenerationUtils = new CodeGenerationUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CodeGenerationUtils getInstnce() {
|
||||||
|
return codeGenerationUtils;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成流程单号
|
* 生成流程单号
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -89,9 +106,7 @@ public class CodeGenerationUtils {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CodeGenerationUtils codeGenerationUtils = new CodeGenerationUtils();
|
|
||||||
|
|
||||||
public static CodeGenerationUtils getInstance() {
|
public static CodeGenerationUtils getInstance() {
|
||||||
return codeGenerationUtils;
|
return CodeGenerationUtilsEnum.INSTANCE.getInstnce();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue