/*
 * Copyright 1999-2018 Alibaba Group Holding Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.alibaba.nacos.api.config;

import com.alibaba.nacos.api.utils.StringUtils;

/**
 * Config data type.
 *
 * @author liaochuntao
 **/
public enum ConfigType {
    
    /**
     * config type is "properties".
     */
    PROPERTIES("properties"),
    
    /**
     * config type is "xml".
     */
    XML("xml"),
    
    /**
     * config type is "json".
     */
    JSON("json"),
    
    /**
     * config type is "text".
     */
    TEXT("text"),
    
    /**
     * config type is "html".
     */
    HTML("html"),
    
    /**
     * config type is "yaml".
     */
    YAML("yaml"),
    
    /**
     * not a real type.
     */
    UNSET("unset");
    
    String type;
    
    ConfigType(String type) {
        this.type = type;
    }
    
    public String getType() {
        return type;
    }
    
    public static ConfigType getDefaultType() {
        return TEXT;
    }
    
    /**
     * check input type is valid.
     *
     * @param type config type
     * @return it the type valid
     */
    public static Boolean isValidType(String type) {
        if (StringUtils.isBlank(type)) {
            return false;
        }
        for (ConfigType value : values()) {
            if (value.type.equals(type)) {
                return true;
            }
        }
        return false;
    }
}

@@ -698,16 +698,65 @@
 Utils;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * C
@@ -1335,20 +1335,279 @@
     
-String type;
+private final String type;%0A    %0A    private static final Map%3CString, ConfigType%3E LOCAL_MAP = new HashMap%3CString, ConfigType%3E();%0A    %0A    static %7B%0A        for (ConfigType configType : values()) %7B%0A            LOCAL_MAP.put(configType.getType(), configType);%0A        %7D%0A    %7D
 %0A   
@@ -2080,154 +2080,51 @@
     
-for (ConfigType value : values()) %7B%0A            if (value.type.equals(type)) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return
+return null != LOCAL_MAP.get(type) ? true :
  fal

Optimize the ConfigType.isValidType method (#5434)