Package org.simpleframework.util
Class KeyMap<T>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,T>
-
- org.simpleframework.util.KeyMap<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<java.lang.String>
,java.util.Map<java.lang.String,T>
public class KeyMap<T> extends java.util.HashMap<java.lang.String,T> implements java.lang.Iterable<java.lang.String>
TheKeyMap
object is used to represent a map of values keyed using a known string. This also ensures that the keys and the values added to this hash map can be acquired in an independent list of values, ensuring that modifications to the map do not have an impact on the lists provided, and vice versa. The key map can also be used in a fore each look using the string keys.- Author:
- Niall Gallagher
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KeyMap()
Constructor for theKeyMap
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getKeys()
This is used to produce aList
of the keys in the map.java.util.List<T>
getValues()
This is used to produce aList
of the values in the map.java.util.Iterator<java.lang.String>
iterator()
This is used to produce anIterator
of values that can be used to acquire the contents of the key map within a for each loop.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
iterator
public java.util.Iterator<java.lang.String> iterator()
This is used to produce anIterator
of values that can be used to acquire the contents of the key map within a for each loop. The key map can be modified while it is been iterated as the iterator is an independent list of values.- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- this returns an iterator of the keys in the map
-
getKeys
public java.util.List<java.lang.String> getKeys()
This is used to produce aList
of the keys in the map. The list produced is a copy of the internal keys and so can be modified and used without affecting this map object.- Returns:
- this returns an independent list of the key values
-
getValues
public java.util.List<T> getValues()
This is used to produce aList
of the values in the map. The list produced is a copy of the internal values and so can be modified and used without affecting this map object.- Returns:
- this returns an independent list of the values
-
-