# Class KeyMap<T>

java.lang.Object
java.util.AbstractMap<String,T>
java.util.HashMap<String,T>
org.simpleframework.util.KeyMap<T>

All Implemented Interfaces:
  `Serializable, Cloneable, Iterable<String>, Map<String,T>`

public class KeyMap<T> extends HashMap<String,T> implements Iterable<String>
The `KeyMap` 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

## Nested Class Summary

### Nested classes/interfaces inherited from class AbstractMap

`AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

### Nested classes/interfaces inherited from interface Map

`Map.Entry<K,V>`

## Constructor Summary

Constructors
Constructor
Description
`KeyMap()`
Constructor for the `KeyMap` object.

## Method Summary

Modifier and Type
Method
Description
`List<String>`
`getKeys()`
This is used to produce a `List` of the keys in the map.
`List<T>`
`getValues()`
This is used to produce a `List` of the values in the map.
`Iterator<String>`
`iterator()`
This is used to produce an `Iterator` of values that can be used to acquire the contents of the key map within a for each loop.

### Methods inherited from class HashMap

`clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values`

### Methods inherited from class AbstractMap

`equals, hashCode, toString`

### Methods inherited from class Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface Iterable

`forEach, spliterator`

### Methods inherited from interface Map

`equals, hashCode`

## Constructor Details

### KeyMap

public KeyMap()
Constructor for the `KeyMap` object. This creates a hash map that can expose the keys and values of the map as an independent `List` containing the values. This can also be used within a for loop for convenience.

## Method Details

### iterator

public Iterator<String> iterator()
This is used to produce an `Iterator` 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 interface `Iterable<T>`
Returns:
  this returns an iterator of the keys in the map

### getKeys

public List<String> getKeys()
This is used to produce a `List` 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 List<T> getValues()
This is used to produce a `List` 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