public abstract class Configuration extends Object
| Constructor and Description |
|---|
Configuration() |
| Modifier and Type | Method and Description |
|---|---|
String |
get(String key)
Get the setting based on key.
|
Boolean |
getBoolean(String key)
Get the setting based on key in boolean.
|
Boolean |
getBooleanOrDefault(String key,
boolean defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key in boolean. |
Double |
getDouble(String key)
Get the setting based on key in double.
|
Double |
getDoubleOrDefault(String key,
double defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key in double. |
Integer |
getInt(String key)
Get the setting based on key in integer.
|
Integer |
getIntOrDefault(String key,
int defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key in integer. |
Long |
getLong(String key)
Get the setting based on key in long.
|
Long |
getLongOrDefault(String key,
long defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key in long. |
String |
getOrDefault(String key,
String defaultValue)
Returns the value to which the specified key is mapped, or
defaultValue if this map contains no mapping for the key. |
Set<String> |
keys()
Returns a
Set view of the keys contained in this map. |
abstract Configuration |
load()
Based on external locations, load configurations into memory.
|
abstract List<String> |
locations()
Get locations of all configuration files.
|
void |
set(String key,
String value)
Set a value to the specified key.
|
public String get(String key)
key - the specified keypublic String getOrDefault(String key, String defaultValue)
defaultValue if this map contains no mapping for the key.key - the key whose associated value is to be returneddefaultValue - the default mapping of the keypublic Integer getInt(String key)
key - the specified keypublic Integer getIntOrDefault(String key, int defaultValue)
defaultValue if this map contains no mapping for the key in integer.key - the key whose associated value is to be returneddefaultValue - the default mapping of the keypublic Double getDouble(String key)
key - the specified keypublic Double getDoubleOrDefault(String key, double defaultValue)
defaultValue if this map contains no mapping for the key in double.key - the key whose associated value is to be returneddefaultValue - the default mapping of the keypublic Long getLong(String key)
key - the specified keypublic Long getLongOrDefault(String key, long defaultValue)
defaultValue if this map contains no mapping for the key in long.key - the key whose associated value is to be returneddefaultValue - the default mapping of the keypublic Boolean getBoolean(String key)
key - the specified keypublic Boolean getBooleanOrDefault(String key, boolean defaultValue)
defaultValue if this map contains no mapping for the key in boolean.key - the key whose associated value is to be returneddefaultValue - the default mapping of the keypublic Set<String> keys()
Set view of the keys contained in this map.public void set(String key, String value)
key - the specified keyvalue - the setting valuepublic abstract Configuration load()
public abstract List<String> locations()
RECOMMENDED: better to use LinkedList
or ImmutableList to ensure the
loading order of configuration as there may exist different values
with the same key.
Copyright © 2019. All rights reserved.