接口 ConfigFile
- 所有超级接口:
ConfigFileMetadata
- 所有已知子接口:
ConfigKVFile
public interface ConfigFile extends ConfigFileMetadata
- 作者:
- lepdou 2022-03-01
-
方法概要
修饰符和类型 方法 说明 voidaddChangeListener(ConfigFileChangeListener listener)Adding a config file change listener, will trigger a callback when the config file is published<T> TasJson(java.lang.Class<T> objectType, T defaultValue)Deserialize to json object with given class type by gson.<T> TasJson(java.lang.reflect.Type typeOfT, T defaultValue)Deserialize to json object with given class type by gson.java.lang.StringgetContent()Get the content of the configuration file.booleanhasContent()Whether the configuration file contains content.voidremoveChangeListener(ConfigFileChangeListener listener)remove a config file change listener从接口继承的方法 com.tencent.polaris.configuration.api.core.ConfigFileMetadata
getFileGroup, getFileName, getNamespace
-
方法详细资料
-
getContent
java.lang.String getContent()Get the content of the configuration file. If it has not been published, null will be returned- 返回:
- the content of the configuration file
-
asJson
<T> T asJson(java.lang.Class<T> objectType, T defaultValue)Deserialize to json object with given class type by gson. Default value will be returned when content is blank or some error occurred.- 类型参数:
T-- 参数:
objectType- the type of classdefaultValue- the default value- 返回:
- Deserialize result of json object.
-
asJson
<T> T asJson(java.lang.reflect.Type typeOfT, T defaultValue)Deserialize to json object with given class type by gson. Default value will be returned when content is blank or some error occurred.- 类型参数:
T-- 参数:
typeOfT- the type of classdefaultValue- the default value- 返回:
- Deserialize result of json object.
-
hasContent
boolean hasContent()Whether the configuration file contains content. If it has not been published or content is blank string, false will be returned- 返回:
- Whether the configuration file contains content
-
addChangeListener
Adding a config file change listener, will trigger a callback when the config file is published- 参数:
listener- the listener will be added
-
removeChangeListener
remove a config file change listener- 参数:
listener- the listener will be removed
-