public abstract class AbstractConfig extends Object implements Config
| Constructor and Description |
|---|
AbstractConfig() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
String[] |
getArrayProperty(String key,
String delimiter,
String[] defaultValue)
Return the array property value with the given key, or
defaultValue if the key doesn't exist. |
Boolean |
getBooleanProperty(String key,
Boolean defaultValue)
Return the boolean property value with the given key, or
defaultValue if the key
doesn't exist. |
Byte |
getByteProperty(String key,
Byte defaultValue)
Return the byte property value with the given key, or
defaultValue if the key doesn't
exist. |
Date |
getDateProperty(String key,
Date defaultValue)
Return the Date property value with the given name, or
defaultValue if the name doesn't exist. |
Date |
getDateProperty(String key,
String format,
Date defaultValue)
Return the Date property value with the given name, or
defaultValue if the name doesn't exist. |
Date |
getDateProperty(String key,
String format,
Locale locale,
Date defaultValue)
Return the Date property value with the given name, or
defaultValue if the name doesn't exist. |
Double |
getDoubleProperty(String key,
Double defaultValue)
Return the double property value with the given key, or
defaultValue if the key doesn't
exist. |
long |
getDurationProperty(String key,
long defaultValue)
Return the duration property value(in milliseconds) with the given name, or
defaultValue if the name doesn't exist. |
<T extends Enum<T>> |
getEnumProperty(String key,
Class<T> enumType,
T defaultValue)
Return the Enum property value with the given key, or
defaultValue if the key doesn't exist. |
Float |
getFloatProperty(String key,
Float defaultValue)
Return the float property value with the given key, or
defaultValue if the key doesn't
exist. |
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
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetProperty, getPropertyNames, getSourceTypepublic void addChangeListener(ConfigChangeListener listener)
ConfigaddChangeListener in interface Configlistener - the config change listenerpublic void addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys)
ConfigaddChangeListener in interface Configlistener - the config change listenerinterestedKeys - the keys interested by the listenerpublic void addChangeListener(ConfigChangeListener listener, Set<String> interestedKeys, Set<String> interestedKeyPrefixes)
ConfigaddChangeListener in interface 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.
For more details, see ApolloConfigChangeListener.interestedKeyPrefixes()
and String.startsWith(String)public boolean removeChangeListener(ConfigChangeListener listener)
ConfigremoveChangeListener in interface Configlistener - the specific config change listener to removepublic Integer getIntProperty(String key, Integer defaultValue)
ConfigdefaultValue if the key
doesn't exist.getIntProperty in interface 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 in interface 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 in interface Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Float getFloatProperty(String key, Float defaultValue)
ConfigdefaultValue if the key doesn't
exist.getFloatProperty in interface Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Double getDoubleProperty(String key, Double defaultValue)
ConfigdefaultValue if the key doesn't
exist.getDoubleProperty in interface Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Byte getByteProperty(String key, Byte defaultValue)
ConfigdefaultValue if the key doesn't
exist.getByteProperty in interface Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic Boolean getBooleanProperty(String key, Boolean defaultValue)
ConfigdefaultValue if the key
doesn't exist.getBooleanProperty in interface Configkey - the property namedefaultValue - the default value when key is not found or any error occurredpublic String[] getArrayProperty(String key, String delimiter, String[] defaultValue)
ConfigdefaultValue if the key doesn't exist.getArrayProperty in interface Configkey - the property namedelimiter - the delimiter regexdefaultValue - the default value when key is not found or any error occurredpublic <T extends Enum<T>> T getEnumProperty(String key, Class<T> enumType, T defaultValue)
ConfigdefaultValue if the key doesn't exist.getEnumProperty in interface ConfigT - the enumkey - the property nameenumType - the enum classdefaultValue - the default value when key is not found or any error occurredpublic Date getDateProperty(String key, Date defaultValue)
ConfigdefaultValue if the name doesn't exist.
Will try to parse the date with Locale.US and formats as follows: yyyy-MM-dd HH:mm:ss.SSS,
yyyy-MM-dd HH:mm:ss and yyyy-MM-ddgetDateProperty in interface Configkey - the property namedefaultValue - the default value when name is not found or any error occurredpublic Date getDateProperty(String key, String format, Date defaultValue)
ConfigdefaultValue if the name doesn't exist.
Will parse the date with the format specified and Locale.USgetDateProperty in interface Configkey - the property nameformat - the date format, see SimpleDateFormat for more
informationdefaultValue - the default value when name is not found or any error occurredpublic Date getDateProperty(String key, String format, Locale locale, Date defaultValue)
ConfigdefaultValue if the name doesn't exist.getDateProperty in interface Configkey - the property nameformat - the date format, see SimpleDateFormat for more
informationlocale - the locale to usedefaultValue - the default value when name is not found or any error occurredpublic long getDurationProperty(String key, long defaultValue)
ConfigdefaultValue if the name doesn't exist. Please note the format should comply with the follow
example (case insensitive). Examples:
"123MS" -- parses as "123 milliseconds"
"20S" -- parses as "20 seconds"
"15M" -- parses as "15 minutes" (where a minute is 60 seconds)
"10H" -- parses as "10 hours" (where an hour is 3600 seconds)
"2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
"2D3H4M5S123MS" -- parses as "2 days, 3 hours, 4 minutes, 5 seconds and 123 milliseconds"
getDurationProperty in interface Configkey - the property namedefaultValue - the default value when name 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 in interface 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 Ctrip, Inc.. All rights reserved.