public interface Config
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addChangeListener(ConfigChangeListener listener)
Add change listener to this config instance, will be notified when any key is changed in this namespace.
|
void |
addChangeListener(ConfigChangeListener listener,
Set<String> interestedKeys)
Add change listener to this config instance, will only be notified when any of the interested keys is changed
in this namespace.
|
void |
addChangeListener(ConfigChangeListener listener,
Set<String> interestedKeys,
Set<String> interestedKeyPrefixes)
Add change listener to this config instance, will only be notified when any of the interested keys is changed
in this namespace.
|
Integer |
getIntProperty(String key,
Integer defaultValue)
Return the integer property value with the given key, or
defaultValue if the key
doesn't exist. |
Long |
getLongProperty(String key,
Long defaultValue)
Return the long property value with the given key, or
defaultValue if the key doesn't
exist. |
<T> T |
getProperty(String key,
com.google.common.base.Function<String,T> function,
T defaultValue)
Return the user-defined property value with the given key, or
defaultValue if the key doesn't exist. |
String |
getProperty(String key,
String defaultValue)
Return the property value with the given key, or
defaultValue if the key doesn't exist. |
Set<String> |
getPropertyNames()
Return a set of the property names
|
Short |
getShortProperty(String key,
Short defaultValue)
Return the short property value with the given key, or
defaultValue if the key doesn't
exist. |
ConfigSourceType |
getSourceType()
Return the config's source type, i.e. where is the config loaded from
|
boolean |
removeChangeListener(ConfigChangeListener listener)
Remove the change listener
|
String getProperty(String key, String defaultValue)
defaultValue if the key doesn't exist.key - the property namedefaultValue - the default value when key is not found or any error occurredInteger getIntProperty(String key, Integer defaultValue)
defaultValue if the key
doesn't exist.key - the property namedefaultValue - the default value when key is not found or any error occurredLong getLongProperty(String key, Long defaultValue)
defaultValue if the key doesn't
exist.key - the property namedefaultValue - the default value when key is not found or any error occurredShort getShortProperty(String key, Short defaultValue)
defaultValue if the key doesn't
exist.key - the property namedefaultValue - the default value when key is not found or any error occurredvoid addChangeListener(ConfigChangeListener listener)
listener - the config change listenervoid addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys)
listener - the config change listenerinterestedKeys - the keys interested by the listenervoid addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys, Set<String> interestedKeyPrefixes)
listener - the config change listenerinterestedKeys - the keys that the listener is interested ininterestedKeyPrefixes - the key prefixes that the listener is interested in,
e.g. "spring." means that listener is interested in keys that starts with
"spring.", such as "spring.banner", "spring.jpa", etc.
and "application" means that listener is interested in keys that starts
with "application", such as "applicationName", "application.port", etc.boolean removeChangeListener(ConfigChangeListener listener)
listener - the specific config change listener to removeSet<String> getPropertyNames()
<T> T getProperty(String key, com.google.common.base.Function<String,T> function, T defaultValue)
defaultValue if the key doesn't exist.T - user-defined typekey - the property namefunction - the transform Function. from String to user-defined typedefaultValue - the default value when key is not found or any error occurredConfigSourceType getSourceType()
Copyright © 2021 hellothomas. All rights reserved.