Optimize the ConfigType.isValidType method (#5434)
* fix #5432 Optimize the ConfigType.isValidType method * code format
This commit is contained in:
parent
103e671d90
commit
b1e78b6f6d
@ -18,6 +18,9 @@ package com.alibaba.nacos.api.config;
|
||||
|
||||
import com.alibaba.nacos.api.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Config data type.
|
||||
*
|
||||
@ -60,7 +63,15 @@ public enum ConfigType {
|
||||
*/
|
||||
UNSET("unset");
|
||||
|
||||
String type;
|
||||
private final String type;
|
||||
|
||||
private static final Map<String, ConfigType> LOCAL_MAP = new HashMap<String, ConfigType>();
|
||||
|
||||
static {
|
||||
for (ConfigType configType : values()) {
|
||||
LOCAL_MAP.put(configType.getType(), configType);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigType(String type) {
|
||||
this.type = type;
|
||||
@ -84,11 +95,6 @@ public enum ConfigType {
|
||||
if (StringUtils.isBlank(type)) {
|
||||
return false;
|
||||
}
|
||||
for (ConfigType value : values()) {
|
||||
if (value.type.equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null != LOCAL_MAP.get(type) ? true : false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user