Package org.zkoss.chart.util
Class OptionsMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,Object>
-
- org.zkoss.chart.util.OptionsMap<K,V>
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,Object>
,org.zkoss.json.JSONAware
public class OptionsMap<K,V> extends LinkedHashMap<String,Object> implements org.zkoss.json.JSONAware
An options map helper.- Author:
- jumperchen
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description OptionsMap()
OptionsMap(int initialCapacity)
Constructs an empty insertion-ordered OptionsMap instance with the specified initial capacity and a default load factor (0.75).OptionsMap(Object... pairs)
Constructs an empty insertion-ordered OptionsMap instance with the specified pairs that contain keys with values.OptionsMap(String key, Object value)
Constructs an empty insertion-ordered OptionsMap instance with the specified a key with a value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OptionsMap<K,V>
add(String key, Object value)
Adds the key with the value into the map.<E> OptionsList<E>
addNestedList(String key)
Adds to create a nested options list with the given key.OptionsMap<K,V>
addNestedMap(String key)
Adds to create a nested options map with the given key.org.zkoss.json.JSONAware
getParent()
Returns the parent options eitherOptionsMap
orOptionsList
.String
toJSONString()
String
toString()
Encodes this object to a JSON string.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Constructor Detail
-
OptionsMap
public OptionsMap()
-
OptionsMap
public OptionsMap(int initialCapacity)
Constructs an empty insertion-ordered OptionsMap instance with the specified initial capacity and a default load factor (0.75).- Parameters:
initialCapacity
- the initial capacity- Throws:
IllegalArgumentException
- if the initial capacity is negative
-
OptionsMap
public OptionsMap(String key, Object value)
Constructs an empty insertion-ordered OptionsMap instance with the specified a key with a value.- See Also:
HashMap.put(Object, Object)
-
OptionsMap
public OptionsMap(Object... pairs)
Constructs an empty insertion-ordered OptionsMap instance with the specified pairs that contain keys with values.- See Also:
HashMap.put(Object, Object)
-
-
Method Detail
-
getParent
public org.zkoss.json.JSONAware getParent()
Returns the parent options eitherOptionsMap
orOptionsList
. If null, that means the option is root object.
-
add
public OptionsMap<K,V> add(String key, Object value)
Adds the key with the value into the map.- Returns:
- the instance itself.
-
addNestedList
public <E> OptionsList<E> addNestedList(String key)
Adds to create a nested options list with the given key.- Returns:
- a nested options list
-
addNestedMap
public OptionsMap<K,V> addNestedMap(String key)
Adds to create a nested options map with the given key.- Returns:
- a nested options map
-
toJSONString
public String toJSONString()
- Specified by:
toJSONString
in interfaceorg.zkoss.json.JSONAware
-
toString
public String toString()
Encodes this object to a JSON string. It is the same astoJSONString()
.- Overrides:
toString
in classAbstractMap<String,Object>
-
-