de.agilecoders.wicket.jquery
Class ConfigWithFallback

java.lang.Object
  extended by de.agilecoders.wicket.jquery.CombinableConfig
      extended by de.agilecoders.wicket.jquery.ConfigWithFallback
All Implemented Interfaces:
Config, Serializable, org.apache.wicket.util.io.IClusterable

public class ConfigWithFallback
extends CombinableConfig

special config that holds two configurations. One base configuration and a fallback configuration.

Author:
Michael Haitz
See Also:
Serialized Form

Constructor Summary
ConfigWithFallback(Config base, Config fallback)
          Construct.
 
Method Summary
 Map<String,Object> all()
           
<T> boolean
contains(IKey<T> key)
          returns true if given key is set to this config
<T> T
get(IKey<T> key)
          returns the value for the given key.
 boolean isEmpty()
           
<T> ConfigWithFallback
put(IKey<T> key, T value)
          puts a new config to the configuration map.
<T> T
remove(IKey<T> key)
          removes the given key (and its value) from configuration map.
 String toJsonString()
           
 
Methods inherited from class de.agilecoders.wicket.jquery.CombinableConfig
combine, withFallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigWithFallback

public ConfigWithFallback(Config base,
                          Config fallback)
Construct.

Parameters:
base - base configuration
fallback - fallback configuration
Method Detail

toJsonString

public String toJsonString()
Returns:
json string representation of this config

all

public Map<String,Object> all()
Returns:
an immutable map of all key/values

isEmpty

public boolean isEmpty()
Returns:
true, if config map is empty or all keys uses their default value

put

public <T> ConfigWithFallback put(IKey<T> key,
                                  T value)
Description copied from interface: Config
puts a new config to the configuration map. If given value is default value of key then it will be removed. This is necessary to keep the ui code small and clean. Also the given value type will be asserted by IKey implementation.

Parameters:
key - mandatory parameter
value - mandatory parameter
Returns:
same instance for chaining

remove

public <T> T remove(IKey<T> key)
Description copied from interface: Config
removes the given key (and its value) from configuration map.

Parameters:
key - the key to remove

get

public <T> T get(IKey<T> key)
Description copied from interface: Config
returns the value for the given key. If no value is set, the default value will be returned.

Parameters:
key - The key to read.
Returns:
the value.

contains

public <T> boolean contains(IKey<T> key)
Description copied from interface: Config
returns true if given key is set to this config

Parameters:
key - The key to check.
Returns:
true if key exists.


Copyright © 2017. All Rights Reserved.