public class CompositeConfigSource extends AbstractConfigSource
IConfigSource
that delegates method calls to the underline sources. The order in which
values are provided depend on the IConfigSource
s provided. If user asks for key 'foo',
and this composite has three sources, it will first check if the key is found in the first
source, if not it will check the second and if not, the third, else return null or false if
contains(String)
was called.
Implementation note: get methods with a default are implemented in AbstractConfigSource
, if the underlying source overrides one of these methods, then that
implementation will be ignored.
Constructor and Description |
---|
CompositeConfigSource(java.util.Collection<? extends IConfigSource> sources) |
CompositeConfigSource(IConfigSource... sources) |
CompositeConfigSource(com.google.common.collect.ImmutableCollection<? extends IConfigSource> sources) |
CompositeConfigSource(java.lang.Iterable<? extends IConfigSource> sources) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.lang.String key)
Check if the given key can be found in the config.
|
java.lang.String |
get(java.lang.String key)
Get a String associated with the given configuration key.
|
void |
initialize(java.lang.String asgName,
java.lang.String region)
Must be called before any other method.
|
boolean |
isEmpty()
Returns
true if the size is zero. |
void |
set(java.lang.String key,
java.lang.String value)
Set the value for the given key.
|
int |
size()
A non-negative integer indicating a count of elements.
|
public CompositeConfigSource(com.google.common.collect.ImmutableCollection<? extends IConfigSource> sources)
public CompositeConfigSource(java.util.Collection<? extends IConfigSource> sources)
public CompositeConfigSource(java.lang.Iterable<? extends IConfigSource> sources)
public CompositeConfigSource(IConfigSource... sources)
public void initialize(java.lang.String asgName, java.lang.String region)
IConfigSource
initialize
in interface IConfigSource
initialize
in class AbstractConfigSource
public int size()
IConfigSource
public boolean isEmpty()
IConfigSource
true
if the size is zero. May be more efficient than calculating size.isEmpty
in interface IConfigSource
isEmpty
in class AbstractConfigSource
true
if the size is zero otherwise false
.public boolean contains(java.lang.String key)
IConfigSource
contains
in interface IConfigSource
contains
in class AbstractConfigSource
key
- to look up value.public java.lang.String get(java.lang.String key)
IConfigSource
key
- to look up value.public void set(java.lang.String key, java.lang.String value)
IConfigSource
key
- to set value for.value
- to set.