接口 ConfigKVFile
- 所有超级接口:
ConfigFile,ConfigFileMetadata
public interface ConfigKVFile extends ConfigFile
The config file can be converted as key value set. Such as properties、yaml files.
- 作者:
- lepdou 2022-03-01
-
方法概要
修饰符和类型 方法 说明 voidaddChangeListener(ConfigKVFileChangeListener listener)Adding a config file property change listener, will trigger a callback when the config file is publishedjava.lang.String[]getArrayProperty(java.lang.String key, java.lang.String delimiter, java.lang.String[] defaultValue)Auto parse string to array by given delimiter, ordefaultValueif the key doesn't exist \n For example, the source value is v1,v2,v3.java.lang.BooleangetBooleanProperty(java.lang.String key, java.lang.Boolean defaultValue)Get the value of given key as boolean type in the configuration file, ordefaultValueif the key doesn't existjava.lang.BytegetByteProperty(java.lang.String key, java.lang.Byte defaultValue)Get the value of given key as byte type in the configuration file, ordefaultValueif the key doesn't existjava.lang.DoublegetDoubleProperty(java.lang.String key, java.lang.Double defaultValue)Get the value of given key as double type in the configuration file, ordefaultValueif the key doesn't exist<T extends java.lang.Enum<T>>
TgetEnumProperty(java.lang.String key, java.lang.Class<T> enumType, T defaultValue)Auto parse string to enum. default value will be returned when parsed failed.java.lang.FloatgetFloatProperty(java.lang.String key, java.lang.Float defaultValue)Get the value of given key as float type in the configuration file, ordefaultValueif the key doesn't existjava.lang.IntegergetIntProperty(java.lang.String key, java.lang.Integer defaultValue)Get the value of given key as integer type in the configuration file, ordefaultValueif the key doesn't exist<T> TgetJsonProperty(java.lang.String key, java.lang.Class<T> clazz, T defaultValue)Auto parse string to json object. default value will be returned when parsed failed.<T> TgetJsonProperty(java.lang.String key, java.lang.reflect.Type typeOfT, T defaultValue)Auto parse string to json object. default value will be returned when parsed failed.java.lang.LonggetLongProperty(java.lang.String key, java.lang.Long defaultValue)Get the value of given key as long type in the configuration file, ordefaultValueif the key doesn't existjava.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Get the value of given key in the configuration file, ordefaultValueif the key doesn't existjava.util.Set<java.lang.String>getPropertyNames()Get properties for all keysjava.lang.ShortgetShortProperty(java.lang.String key, java.lang.Short defaultValue)Get the value of given key as short type in the configuration file, ordefaultValueif the key doesn't existvoidremoveChangeListener(ConfigKVFileChangeListener listener)Remove a config file property change listener从接口继承的方法 com.tencent.polaris.configuration.api.core.ConfigFile
addChangeListener, asJson, asJson, getContent, hasContent, removeChangeListener从接口继承的方法 com.tencent.polaris.configuration.api.core.ConfigFileMetadata
getFileGroup, getFileName, getNamespace
-
方法详细资料
-
getProperty
java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Get the value of given key in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getIntProperty
java.lang.Integer getIntProperty(java.lang.String key, java.lang.Integer defaultValue)Get the value of given key as integer type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getLongProperty
java.lang.Long getLongProperty(java.lang.String key, java.lang.Long defaultValue)Get the value of given key as long type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getShortProperty
java.lang.Short getShortProperty(java.lang.String key, java.lang.Short defaultValue)Get the value of given key as short type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getFloatProperty
java.lang.Float getFloatProperty(java.lang.String key, java.lang.Float defaultValue)Get the value of given key as float type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getDoubleProperty
java.lang.Double getDoubleProperty(java.lang.String key, java.lang.Double defaultValue)Get the value of given key as double type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getByteProperty
java.lang.Byte getByteProperty(java.lang.String key, java.lang.Byte defaultValue)Get the value of given key as byte type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getBooleanProperty
java.lang.Boolean getBooleanProperty(java.lang.String key, java.lang.Boolean defaultValue)Get the value of given key as boolean type in the configuration file, ordefaultValueif the key doesn't exist- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- the properties value
-
getArrayProperty
java.lang.String[] getArrayProperty(java.lang.String key, java.lang.String delimiter, java.lang.String[] defaultValue)Auto parse string to array by given delimiter, ordefaultValueif the key doesn't exist \n For example, the source value is v1,v2,v3. An array ["v1","v2","v3"] will be returned when called with "," delimiter.- 参数:
key- the properties keydefaultValue- the default value when key is not found or any error occurred- 返回:
- parsed array
-
getEnumProperty
<T extends java.lang.Enum<T>> T getEnumProperty(java.lang.String key, java.lang.Class<T> enumType, T defaultValue)Auto parse string to enum. default value will be returned when parsed failed.- 类型参数:
T-- 参数:
key- the properties keyenumType- the type of enumdefaultValue- the default value when key is not found or any error occurred- 返回:
- parsed enum
-
getJsonProperty
<T> T getJsonProperty(java.lang.String key, java.lang.Class<T> clazz, T defaultValue)Auto parse string to json object. default value will be returned when parsed failed.- 类型参数:
T-- 参数:
key- the properties keyclazz- the type of objectdefaultValue- the default value when key is not found or any error occurred- 返回:
- parsed object
-
getJsonProperty
<T> T getJsonProperty(java.lang.String key, java.lang.reflect.Type typeOfT, T defaultValue)Auto parse string to json object. default value will be returned when parsed failed.- 类型参数:
T-- 参数:
key- the properties keytypeOfT- the type of objectdefaultValue- the default value when key is not found or any error occurred- 返回:
- parsed object
-
getPropertyNames
java.util.Set<java.lang.String> getPropertyNames()Get properties for all keys- 返回:
- the keys in properties
-
addChangeListener
Adding a config file property change listener, will trigger a callback when the config file is published- 参数:
listener- the listener will be added
-
removeChangeListener
Remove a config file property change listener- 参数:
listener- the listener will be removed
-