Class SingleEntryMap<K,V>

java.lang.Object
org.apache.cayenne.util.SingleEntryMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>, Map.Entry<K,V>

public class SingleEntryMap<K,V> extends Object implements Map<K,V>, Map.Entry<K,V>, Serializable
Optimized mutable single-entry map.

This implementation is compatible with general Map contract, including Map.equals(Object), Map.hashCode() and AbstractMap.toString() implementations.

This Map can store only one key that is defined at creation time and can't be changed. This map will throw IllegalArgumentException on any put operation with the wrong key and return null on get.

This map will be effectively empty after putting null value.

Since:
4.2
See Also:
  • Constructor Details

    • SingleEntryMap

      public SingleEntryMap(K key)
      Create empty map
      Parameters:
      key - that can be stored in this map, can't be null
    • SingleEntryMap

      public SingleEntryMap(K key, V value)
      Create map with single key-value entry
      Parameters:
      key - that can be stored in this map, can't be null
      value - to store, if null map will be empty.
  • Method Details