|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.prefs.config.backend.FallbackConfigurationBackend
public class FallbackConfigurationBackend
A ConfigurationBackend
that supports fallback mechanisms.
The FallbackConfigurationBackend
distguishes between the
#primaries
and their fallbacks
. The first are
an arbitrary ConfigurationBackend
and the latter is a
Map
the defines fallbacks for the ISetting
s through
<name,fallbackName> pairs.
Thus if a ISetting
is to be retrieved and not found
in the #primaries
the fallbacks
will be queried
and if there's such a fallback ISetting
it will be retrieved
from the #primaries
instead of the requested one.
Note that the fallback retrieval is done recursively and will
resolve indirect/mutiple fallbacks, too!
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
fallbacks
|
protected ConfigurationBackend |
primarySettings
|
Constructor Summary | |
---|---|
FallbackConfigurationBackend(ConfigurationBackend primarySettings,
java.util.Map<java.lang.String,java.lang.String> fallbacks)
|
Method Summary | |
---|---|
ISetting |
get(java.lang.String name)
Retrieves the ISetting with the passed name. |
java.util.List<ISetting> |
getSettings()
Adds all #primaries as well as all
fallbacks for which there's no primary one. |
boolean |
isPrimarySetting(java.lang.String name)
|
void |
set(ISetting setting)
Sets the passed setting which must not be null
in this configuration backend, if a setting with the given
name is already present it will be overridden. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ConfigurationBackend primarySettings
protected java.util.Map<java.lang.String,java.lang.String> fallbacks
Constructor Detail |
---|
public FallbackConfigurationBackend(ConfigurationBackend primarySettings, java.util.Map<java.lang.String,java.lang.String> fallbacks)
primaries
- - the primary ISetting
sfallbacks
- - the mapping of primary to fallback primariesMethod Detail |
---|
public ISetting get(java.lang.String name) throws java.lang.IllegalArgumentException
ConfigurationBackend
ISetting
with the passed name.
get
in interface ConfigurationBackend
ISetting
with the
passed name or null
if not present.
java.lang.IllegalArgumentException
- - if the passed name is
null
.com.emarsys.core.setting.backend.ConfigurationBackend#get(java.lang.String)
public void set(ISetting setting) throws java.lang.IllegalArgumentException
ConfigurationBackend
null
in this configuration backend, if a setting with the given
name is already present it will be overridden.
The next call to ConfigurationBackend.get(String)
with the passed
setting's name will return the passed setting.
set
in interface ConfigurationBackend
java.lang.IllegalArgumentException
- - if the passed setting,
its name or value is null
.com.emarsys.core.setting.backend.ConfigurationBackend#set(ISetting)
public java.util.List<ISetting> getSettings()
#primaries
as well as all
fallbacks
for which there's no primary one.
getSettings
in interface ConfigurationBackend
List
of ISetting
s,
never null
.com.emarsys.core.setting.backend.ConfigurationBackend#getSettings()
public boolean isPrimarySetting(java.lang.String name)
name
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |