de.agilecoders.wicket.jquery
Class AbstractConfig

java.lang.Object
  extended by de.agilecoders.wicket.jquery.CombinableConfig
      extended by de.agilecoders.wicket.jquery.AbstractConfig
All Implemented Interfaces:
Config, Serializable, org.apache.wicket.util.io.IClusterable
Direct Known Subclasses:
MutableConfig

public abstract class AbstractConfig
extends CombinableConfig

Base configuration class.

Author:
Michael Haitz
See Also:
Serialized Form

Constructor Summary
protected AbstractConfig()
          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.
protected
<T> String
getString(IKey<T> key)
          returns the value as string according to given key.
 boolean isEmpty()
           
protected static
<T> IKey<T>
newKey(String key, T defaultValue)
          creates a new key.
<T> AbstractConfig
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()
           
protected  ConfigModel wrap(org.apache.wicket.model.IModel<String> model)
          Wraps IModel<String> in ConfigModel to serialize it as simple String in the produced JSON.
 
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

AbstractConfig

protected AbstractConfig()
Construct.

Method Detail

toJsonString

public final String toJsonString()
Returns:
current configuration as json string

all

public final Map<String,Object> all()
Returns:
an immutable view of all configurations

isEmpty

public final boolean isEmpty()
Returns:
true, if no special configuration is set.

put

public final <T> AbstractConfig put(IKey<T> key,
                                    T value)
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

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.

remove

public final <T> T remove(IKey<T> key)
removes the given key (and its value) from configuration map.

Parameters:
key - the key to remove

getString

protected final <T> String getString(IKey<T> key)
returns the value as string according to given key. If no value is set, the default value will be returned.

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

get

public final <T> T get(IKey<T> key)
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.

wrap

protected ConfigModel wrap(org.apache.wicket.model.IModel<String> model)
Wraps IModel<String> in ConfigModel to serialize it as simple String in the produced JSON.

Parameters:
model - The model to wrap.
Returns:
A model that uses special Json serializer

newKey

protected static <T> IKey<T> newKey(String key,
                                    T defaultValue)
creates a new key.

Parameters:
key - string representation of this key
defaultValue - The default value


Copyright © 2017. All Rights Reserved.