public interface Config
| 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. |
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.
|
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 occurredFloat getFloatProperty(String key, Float defaultValue)
defaultValue if the key doesn't
exist.key - the property namedefaultValue - the default value when key is not found or any error occurredDouble getDoubleProperty(String key, Double defaultValue)
defaultValue if the key doesn't
exist.key - the property namedefaultValue - the default value when key is not found or any error occurredByte getByteProperty(String key, Byte defaultValue)
defaultValue if the key doesn't
exist.key - the property namedefaultValue - the default value when key is not found or any error occurredBoolean getBooleanProperty(String key, Boolean defaultValue)
defaultValue if the key
doesn't exist.key - the property namedefaultValue - the default value when key is not found or any error occurredString[] getArrayProperty(String key, String delimiter, String[] defaultValue)
defaultValue if the key doesn't exist.key - the property namedelimiter - the delimiter regexdefaultValue - the default value when key is not found or any error occurredDate getDateProperty(String key, Date defaultValue)
defaultValue 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-ddkey - the property namedefaultValue - the default value when name is not found or any error occurredDate getDateProperty(String key, String format, Date defaultValue)
defaultValue if the name doesn't exist.
Will parse the date with the format specified and Locale.USkey - the property nameformat - the date format, see SimpleDateFormat for more
informationdefaultValue - the default value when name is not found or any error occurredDate getDateProperty(String key, String format, Locale locale, Date defaultValue)
defaultValue if the name doesn't exist.key - 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 occurred<T extends Enum<T>> T getEnumProperty(String key, Class<T> enumType, T defaultValue)
defaultValue if the key doesn't exist.T - the enumkey - the property nameenumType - the enum classdefaultValue - the default value when key is not found or any error occurredlong getDurationProperty(String key, long defaultValue)
defaultValue 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"
key - the property namedefaultValue - the default value when name 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.
For more details, see ApolloConfigChangeListener.interestedKeyPrefixes()
and String.startsWith(String)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 © 2022 Ctrip, Inc.. All rights reserved.