refactor(nacos-api:config): Modify ConfigYype to be an enumeration class

This commit is contained in:
chuntaojun 2019-06-17 18:31:50 +08:00
parent 22df13b0e2
commit 44e3c5e224
3 changed files with 26 additions and 9 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 = the "License");
* 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
*
@ -20,36 +20,45 @@ package com.alibaba.nacos.api.config;
* @author liaochuntao
* @date 2019-06-14 21:12
**/
public class ConfigType {
public enum ConfigType {
/**
* config type is "properties"
*/
public static final String PROPERTIES = "properties";
PROPERTIES("properties"),
/**
* config type is "xml"
*/
public static final String XML = "xml";
XML("xml"),
/**
* config type is "json"
*/
public static final String JSON = "json";
JSON("json"),
/**
* config type is "text"
*/
public static final String TEXT = "text";
TEXT("text"),
/**
* config type is "html"
*/
public static final String HTML = "html";
HTML("html"),
/**
* config type is "yaml"
*/
public static final String YAML = "yaml";
YAML("yaml");
String type;
ConfigType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}

View File

@ -17,6 +17,7 @@ package com.alibaba.nacos.api.config.annotation;
import com.alibaba.nacos.api.annotation.NacosProperties;
import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.config.ConfigType;
import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
import java.lang.annotation.*;
@ -48,6 +49,13 @@ public @interface NacosConfigListener {
*/
String dataId();
/**
* Nacos Config type
*
* @return "properties"
*/
ConfigType type() default ConfigType.PROPERTIES;
/**
* Specify {@link NacosConfigConverter Nacos configuraion convertor} class to convert target type instance.
*

View File

@ -55,7 +55,7 @@ public @interface NacosConfigurationProperties {
*
* @return default value is <code>false</code>
*/
String type() default ConfigType.PROPERTIES;
ConfigType type() default ConfigType.PROPERTIES;
/**
* It indicates the properties of current doBind bean is auto-refreshed when Nacos configuration is changed.