de.unkrig.commons.util.collections
Class MapUtil

java.lang.Object
  extended by de.unkrig.commons.util.collections.MapUtil

public final class MapUtil
extends java.lang.Object

Various utility methods for map processing.


Method Summary
static
<K,V> java.util.Map<K,V>
augment(java.util.Map<K,V> delegate, K extraKey, V extraValue)
          Returns a Map that is composed of the delegate and one extra entry.
static
<K,V> java.util.Map<K,V>
combine(java.util.Map<K,V> map1, java.util.Map<K,V> map2)
          Returns a Map that is composed of the delegate and the parent.
static boolean equal(java.lang.Object o1, java.lang.Object o2)
          The often-needed "equal" method that handles null references.
static
<K,V> java.util.Map<K,V>
fromMappings(java.lang.Object... keysAndValues)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

combine

public static <K,V> java.util.Map<K,V> combine(java.util.Map<K,V> map1,
                                               java.util.Map<K,V> map2)
Returns a Map that is composed of the delegate and the parent. The parent is never modified.


augment

public static <K,V> java.util.Map<K,V> augment(java.util.Map<K,V> delegate,
                                               K extraKey,
                                               V extraValue)
Returns a Map that is composed of the delegate and one extra entry.


equal

public static boolean equal(@Nullable
                            java.lang.Object o1,
                            @Nullable
                            java.lang.Object o2)
The often-needed "equal" method that handles null references.

Redeemed by java.util.Objects.equals(Object, Object) which is available since Java 1.7.


fromMappings

public static <K,V> java.util.Map<K,V> fromMappings(java.lang.Object... keysAndValues)
Parameters:
keysAndValues - An even-sized array filled alternatingly with objects of type K and V
Returns:
An unmodifiable Map populated from the given key/value pairs