public abstract class AbstractConfig extends Object implements Config
| 构造器和说明 |
|---|
AbstractConfig() |
| 限定符和类型 | 方法和说明 |
|---|---|
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. |
Short |
getShortProperty(String key,
Short defaultValue)
Return the short property value with the given key, or
defaultValue if the key doesn't
exist. |
boolean |
removeChangeListener(ConfigChangeListener listener)
Remove the change listener
|
getProperty, getPropertyNames, getSourceTypepublic void addChangeListener(ConfigChangeListener listener)
ConfigaddChangeListener 在接口中 Configlistener - the config change listenerpublic void addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys)
ConfigaddChangeListener 在接口中 Configlistener - the config change listenerinterestedKeys - the keys interested by the listenerpublic void addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys, Set<String> interestedKeyPrefixes)
ConfigaddChangeListener 在接口中 Configlistener - 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.public boolean removeChangeListener(ConfigChangeListener listener)
ConfigremoveChangeListener 在接口中 Configlistener - the specific config change listener to removepublic Integer getIntProperty(String key, Integer defaultValue)
ConfigdefaultValue if the key
doesn't exist.getIntProperty 在接口中 Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Long getLongProperty(String key, Long defaultValue)
ConfigdefaultValue if the key doesn't
exist.getLongProperty 在接口中 Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Short getShortProperty(String key, Short defaultValue)
ConfigdefaultValue if the key doesn't
exist.getShortProperty 在接口中 Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic <T> T getProperty(String key, com.google.common.base.Function<String,T> function, T defaultValue)
ConfigdefaultValue if the key doesn't exist.getProperty 在接口中 ConfigT - 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 occurredCopyright © 2022 hellothomas. All rights reserved.