JBoss Modular Service Kernel API 1.0.0.CR2

org.jboss.msc.value
Class MapEntry<K,V>

java.lang.Object
  extended by org.jboss.msc.value.MapEntry<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Serializable, Map.Entry<K,V>

public final class MapEntry<K,V>
extends Object
implements Map.Entry<K,V>, Serializable

An immutable key-value object for constructing map instances programmatically.

See Also:
Serialized Form

Constructor Summary
MapEntry(K key, V value)
          Construct a new instance.
 
Method Summary
static
<K,V> Map<K,V>
addTo(Map<K,V> map, MapEntry<? extends K,? extends V>... entries)
          Add entries to a map.
static
<K,V> MapEntry<K,V>
entry(K key, V value)
          Construct a new instance.
 boolean equals(MapEntry<?,?> obj)
          Compare this entry with another.
 boolean equals(Object obj)
          Compare this entry with another.
 K getKey()
          Get the map key.
 V getValue()
          Get the map value.
 int hashCode()
          Get the hash code of this object.
 V setValue(V value)
          Unsupported operation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapEntry

public MapEntry(K key,
                V value)
Construct a new instance.

Parameters:
key - the map key
value - the map value
Method Detail

entry

public static <K,V> MapEntry<K,V> entry(K key,
                                        V value)
Construct a new instance.

Type Parameters:
K - the key type
V - the value type
Parameters:
key - the map key
value - the map value
Returns:
the entry

getKey

public K getKey()
Get the map key.

Specified by:
getKey in interface Map.Entry<K,V>
Returns:
the map key

getValue

public V getValue()
Get the map value.

Specified by:
getValue in interface Map.Entry<K,V>
Returns:
the map value

setValue

public V setValue(V value)
Unsupported operation.

Specified by:
setValue in interface Map.Entry<K,V>
Parameters:
value - ignored
Returns:
nothing
Throws:
UnsupportedOperationException - always

equals

public boolean equals(Object obj)
Compare this entry with another.

Specified by:
equals in interface Map.Entry<K,V>
Overrides:
equals in class Object
Parameters:
obj - the other entry
Returns:
true if this object equals the other MapEntry instance, false otherwise

equals

public boolean equals(MapEntry<?,?> obj)
Compare this entry with another.

Parameters:
obj - the other entry
Returns:
true if this object equals the other MapEntry instance, false otherwise

hashCode

public int hashCode()
Get the hash code of this object.

Specified by:
hashCode in interface Map.Entry<K,V>
Overrides:
hashCode in class Object
Returns:
the hash code

addTo

public static <K,V> Map<K,V> addTo(Map<K,V> map,
                                   MapEntry<? extends K,? extends V>... entries)
Add entries to a map.

Type Parameters:
K - the key type
V - the value type
Parameters:
map - the map to add to
entries - the entries to add
Returns:
the map

JBoss Modular Service Kernel API 1.0.0.CR2

Copyright © 2011 JBoss, a division of Red Hat, Inc.