hudson.plugins.violations.util
Class HashMapWithDefault<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by hudson.plugins.violations.util.HashMapWithDefault<K,V>
Type Parameters:
K - the type of key for this map.
V - the type of mapped value.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>

public class HashMapWithDefault<K,V>
extends java.util.HashMap<K,V>

An extension of a hash map with a default value for keys not present.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
HashMapWithDefault(V defaultValue)
          Construct a new hash map.
 
Method Summary
 V get(java.lang.Object k)
          Get a value for a key.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

HashMapWithDefault

public HashMapWithDefault(V defaultValue)
Construct a new hash map.

Parameters:
defaultValue - the value to use if a key cannot be found.
Method Detail

get

public V get(java.lang.Object k)
Get a value for a key.

Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class java.util.HashMap<K,V>
Parameters:
k - the key to use to lookup the map.
Returns:
the value for the key, or the default value if the key is not in the map.


Copyright © 2004-2012. All Rights Reserved.