接口 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
  • 方法概要

    修饰符和类型 方法 说明
    void addChangeListener​(ConfigKVFileChangeListener listener)
    Adding a config file property change listener, will trigger a callback when the config file is published
    java.lang.String[] getArrayProperty​(java.lang.String key, java.lang.String delimiter, java.lang.String[] defaultValue)
    Auto parse string to array by given delimiter, or defaultValue if the key doesn't exist \n For example, the source value is v1,v2,v3.
    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, or defaultValue if the key doesn't exist
    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, or defaultValue if the key doesn't exist
    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, or defaultValue if the key doesn't exist
    <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.
    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, or defaultValue if the key doesn't exist
    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, or defaultValue if the key doesn't exist
    <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> 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.
    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, or defaultValue if the key doesn't exist
    java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
    Get the value of given key in the configuration file, or defaultValue if the key doesn't exist
    java.util.Set<java.lang.String> getPropertyNames()
    Get properties for all keys
    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, or defaultValue if the key doesn't exist
    void removeChangeListener​(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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if the key doesn't exist
      参数:
      key - the properties key
      defaultValue - 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, or defaultValue if 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 key
      defaultValue - 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 key
      enumType - the type of enum
      defaultValue - 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 key
      clazz - the type of object
      defaultValue - 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 key
      typeOfT - the type of object
      defaultValue - 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

      void addChangeListener​(ConfigKVFileChangeListener listener)
      Adding a config file property change listener, will trigger a callback when the config file is published
      参数:
      listener - the listener will be added
    • removeChangeListener

      void removeChangeListener​(ConfigKVFileChangeListener listener)
      Remove a config file property change listener
      参数:
      listener - the listener will be removed