Class DataMap<K>

  • Type Parameters:
    K - Type of keys in this map.

    public final class DataMap<K>
    extends Object
    An opaque, strongly typed heterogeneous data container. Data maps can be set to accept only a certain type of key, with the type parameter. The key can itself constrain the type of values, using its own type parameter T.
    • Method Detail

      • set

        public <T> T set​(DataMap.DataKey<? extends K,​? super T> key,
                         T data)
        Set the mapping to the given data.
        Type Parameters:
        T - Type of the data
        Parameters:
        key - Key
        data - Data mapped to the key
        Returns:
        Previous value associated with the key (nullable)
      • get

        public <T> T get​(DataMap.DataKey<? extends K,​? super T> key)
        Retrieves the data currently mapped to the key.
        Type Parameters:
        T - Type of the data
        Parameters:
        key - Key
        Returns:
        Value associated with the key (nullable)
      • isSet

        public boolean isSet​(DataMap.DataKey<? extends K,​?> key)
        Returns true if the given key has a non-null value in the map.
        Parameters:
        key - Key
        Returns:
        True if some value is set
      • newDataMap

        public static <K> DataMap<K> newDataMap()