Skip to content

Commit

Permalink
perf: final方法改为大写命名
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyuv committed Aug 11, 2022
1 parent e1b8ae0 commit e5bd517
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DictFrameworkUtils {
/**
* 针对 {@link #getDictDataLabel(String, String)} 的缓存
*/
private static final LoadingCache<KeyValue<String, String>, DictDataRespDTO> getDictDataCache = CacheUtils.buildAsyncReloadingCache(
private static final LoadingCache<KeyValue<String, String>, DictDataRespDTO> GET_DICT_DATA_CACHE = CacheUtils.buildAsyncReloadingCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<String, String>, DictDataRespDTO>() {

Expand All @@ -41,7 +41,7 @@ public DictDataRespDTO load(KeyValue<String, String> key) {
/**
* 针对 {@link #parseDictDataValue(String, String)} 的缓存
*/
private static final LoadingCache<KeyValue<String, String>, DictDataRespDTO> parseDictDataCache = CacheUtils.buildAsyncReloadingCache(
private static final LoadingCache<KeyValue<String, String>, DictDataRespDTO> PARSE_DICT_DATA_CACHE = CacheUtils.buildAsyncReloadingCache(
Duration.ofMinutes(1L), // 过期时间 1 分钟
new CacheLoader<KeyValue<String, String>, DictDataRespDTO>() {

Expand All @@ -59,12 +59,12 @@ public static void init(DictDataApi dictDataApi) {

@SneakyThrows
public static String getDictDataLabel(String dictType, String value) {
return getDictDataCache.get(new KeyValue<>(dictType, value)).getLabel();
return GET_DICT_DATA_CACHE.get(new KeyValue<>(dictType, value)).getLabel();
}

@SneakyThrows
public static String parseDictDataValue(String dictType, String label) {
return parseDictDataCache.get(new KeyValue<>(dictType, label)).getValue();
return PARSE_DICT_DATA_CACHE.get(new KeyValue<>(dictType, label)).getValue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
public class JsonLongSetTypeHandler extends AbstractJsonTypeHandler<Object> {

private static final TypeReference<Set<Long>> typeReference = new TypeReference<Set<Long>>(){};
private static final TypeReference<Set<Long>> TYPE_REFERENCE = new TypeReference<Set<Long>>(){};

@Override
protected Object parse(String json) {
return JsonUtils.parseObject(json, typeReference);
return JsonUtils.parseObject(json, TYPE_REFERENCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public class RedisKeyRegistry {
/**
* Redis RedisKeyDefine 数组
*/
private static final List<RedisKeyDefine> defines = new ArrayList<>();
private static final List<RedisKeyDefine> DEFINES = new ArrayList<>();

public static void add(RedisKeyDefine define) {
defines.add(define);
DEFINES.add(define);
}

public static List<RedisKeyDefine> list() {
return defines;
return DEFINES;
}

public static int size() {
return defines.size();
return DEFINES.size();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ public class TransmittableThreadLocalSecurityContextHolderStrategy implements Se
/**
* 使用 TransmittableThreadLocal 作为上下文
*/
private static final ThreadLocal<SecurityContext> contextHolder = new TransmittableThreadLocal<>();
private static final ThreadLocal<SecurityContext> CONTEXT_HOLDER = new TransmittableThreadLocal<>();

@Override
public void clearContext() {
contextHolder.remove();
CONTEXT_HOLDER.remove();
}

@Override
public SecurityContext getContext() {
SecurityContext ctx = contextHolder.get();
SecurityContext ctx = CONTEXT_HOLDER.get();
if (ctx == null) {
ctx = createEmptyContext();
contextHolder.set(ctx);
CONTEXT_HOLDER.set(ctx);
}
return ctx;
}

@Override
public void setContext(SecurityContext context) {
Assert.notNull(context, "Only non-null SecurityContext instances are permitted");
contextHolder.set(context);
CONTEXT_HOLDER.set(context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CodegenBuilder {
* 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射
* 注意,字段的匹配以后缀的方式
*/
private static final Map<String, CodegenColumnListConditionEnum> columnListOperationConditionMappings =
private static final Map<String, CodegenColumnListConditionEnum> COLUMN_LIST_OPERATION_CONDITION_MAPPINGS =
MapUtil.<String, CodegenColumnListConditionEnum>builder()
.put("name", CodegenColumnListConditionEnum.LIKE)
.put("time", CodegenColumnListConditionEnum.BETWEEN)
Expand All @@ -42,7 +42,7 @@ public class CodegenBuilder {
* 字段名与 {@link CodegenColumnHtmlTypeEnum} 的默认映射
* 注意,字段的匹配以后缀的方式
*/
private static final Map<String, CodegenColumnHtmlTypeEnum> columnHtmlTypeMappings =
private static final Map<String, CodegenColumnHtmlTypeEnum> COLUMN_HTML_TYPE_MAPPINGS =
MapUtil.<String, CodegenColumnHtmlTypeEnum>builder()
.put("status", CodegenColumnHtmlTypeEnum.RADIO)
.put("sex", CodegenColumnHtmlTypeEnum.RADIO)
Expand Down Expand Up @@ -143,7 +143,7 @@ private void processColumnOperation(CodegenColumnDO column) {
column.setListOperation(!LIST_OPERATION_EXCLUDE_COLUMN.contains(column.getJavaField())
&& !column.getPrimaryKey()); // 对于主键,列表过滤不需要传递
// 处理 listOperationCondition 字段
columnListOperationConditionMappings.entrySet().stream()
COLUMN_LIST_OPERATION_CONDITION_MAPPINGS.entrySet().stream()
.filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.findFirst().ifPresent(entry -> column.setListOperationCondition(entry.getValue().getCondition()));
if (column.getListOperationCondition() == null) {
Expand All @@ -155,7 +155,7 @@ private void processColumnOperation(CodegenColumnDO column) {

private void processColumnUI(CodegenColumnDO column) {
// 基于后缀进行匹配
columnHtmlTypeMappings.entrySet().stream()
COLUMN_HTML_TYPE_MAPPINGS.entrySet().stream()
.filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
.findFirst().ifPresent(entry -> column.setHtmlType(entry.getValue().getType()));
// 如果是 Boolean 类型时,设置为 radio 类型.
Expand Down

0 comments on commit e5bd517

Please sign in to comment.