Interface Dictionary<K,​V>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Dictionary.Pair<K,​V>
      Class representing a key/value pair.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean containsAny​(K... keys)
      Determines if any of the given keys exists in the dictionary.
      boolean containsKey​(K key)
      Tests the existence of a key in the dictionary.
      default java.lang.Object copy​(K key, Dictionary<K,​V> source)
      Copy the value from one dictionary to this one.
      V get​(K key)
      Retrieves the value for the given key.
      default boolean getBoolean​(K key)
      Using the other methods in this interface, retrieve a boolean value from this dictionary; returning false if the key does not exist.
      default boolean getBoolean​(K key, boolean defaultValue)
      Using the other methods in this interface, retrieve a boolean value from this dictionary; returning a default value if the key does not exist.
      default java.awt.Color getColor​(K key)
      Using the other methods in this interface, retrieve a Color value from this dictionary; returning null if the key does not exist.
      default V getFirst​(K... keys)
      Retrieves the value of the first of the given keys that exists in the dictionary (that is, the first key for which containsKey(K) returns true).
      default java.awt.Font getFont​(K key)
      Using the other methods in this interface, retrieve a Font value from this dictionary; returning null if the key does not exist.
      default int getInt​(K key)
      Using the other methods in this interface, retrieve an integer value from this dictionary; returning 0 if the key does not exist.
      default int getInt​(K key, int defaultValue)
      Using the other methods in this interface, retrieve an integer value from this dictionary; returning the given default if the key does not exist.
      default java.lang.String getString​(K key)
      Retrieve a String value from this dictionary; returning null if the key does not exist.
      default java.lang.String getString​(K key, java.lang.String defaultValue)
      Retrieve a String value from this dictionary; returning null if the key does not exist.
      V put​(K key, V value)
      Sets the value of the given key, creating a new entry or replacing the existing value.
      default void putAll​(Map<K,​V> map)
      Put all the key/value pairs from the given map into this dictionary.
      V remove​(K key)
      Removes a key/value pair from the map.
    • Method Detail

      • get

        V get​(K key)
        Retrieves the value for the given key.
        Parameters:
        key - The key whose value is to be returned.
        Returns:
        The value corresponding to key, or null if the key does not exist. Will also return null if the key refers to a null value. Use containsKey(K) to distinguish between these two cases.
      • put

        V put​(K key,
              V value)
        Sets the value of the given key, creating a new entry or replacing the existing value.
        Parameters:
        key - The key whose value is to be set.
        value - The value to be associated with the given key.
        Returns:
        The value previously associated with the key.
      • remove

        V remove​(K key)
        Removes a key/value pair from the map.
        Parameters:
        key - The key whose mapping is to be removed.
        Returns:
        The value that was removed.
      • containsKey

        boolean containsKey​(K key)
        Tests the existence of a key in the dictionary.
        Parameters:
        key - The key whose presence in the dictionary is to be tested.
        Returns:
        true if the key exists in the dictionary; false, otherwise.
      • containsAny

        default boolean containsAny​(K... keys)
        Determines if any of the given keys exists in the dictionary.
        Parameters:
        keys - The list of keys to search for in the dictionary.
        Returns:
        true if containsKey(K) returns true for any of the given keys, or false if none of the keys exist.
      • getFirst

        default V getFirst​(K... keys)
        Retrieves the value of the first of the given keys that exists in the dictionary (that is, the first key for which containsKey(K) returns true).
        Parameters:
        keys - The list of keys to search for in the dictionary.
        Returns:
        The first value found, or null if either the value is null for the first key found, or none of the keys exists in the dictionary. Use containsAny(K...) to determine the difference.
      • getString

        default java.lang.String getString​(K key)
        Retrieve a String value from this dictionary; returning null if the key does not exist.
        Parameters:
        key - The key for the (supposed) String value.
        Returns:
        The string value, or null if the key is not present.
      • getString

        default java.lang.String getString​(K key,
                                           java.lang.String defaultValue)
        Retrieve a String value from this dictionary; returning null if the key does not exist.
        Parameters:
        key - The key for the (supposed) String value.
        defaultValue - The string to return if the key is not present.
        Returns:
        The string value, or the default value if the key is not present.
      • getInt

        default int getInt​(K key)
        Using the other methods in this interface, retrieve an integer value from this dictionary; returning 0 if the key does not exist.
        Parameters:
        key - The key for the (supposed) Integer value to retrieve (actually any Number will work).
        Returns:
        The integer value, or 0 if the key is not present.
      • getInt

        default int getInt​(K key,
                           int defaultValue)
        Using the other methods in this interface, retrieve an integer value from this dictionary; returning the given default if the key does not exist.
        Parameters:
        key - The key for the (supposed) Integer value to retrieve (actually any Number will work).
        defaultValue - The value to return if the key is not present.
        Returns:
        The integer value, or the default value if the key is not present.
      • getBoolean

        default boolean getBoolean​(K key)
        Using the other methods in this interface, retrieve a boolean value from this dictionary; returning false if the key does not exist.
        Parameters:
        key - The key for the (supposed) Boolean value to retrieve.
        Returns:
        The boolean value, or false if the key is not present.
      • getBoolean

        default boolean getBoolean​(K key,
                                   boolean defaultValue)
        Using the other methods in this interface, retrieve a boolean value from this dictionary; returning a default value if the key does not exist.
        Parameters:
        key - The key for the (supposed) Boolean value to retrieve.
        defaultValue - What to return if the key is not present.
        Returns:
        The boolean value, or the default if the key is not present.
      • getColor

        default java.awt.Color getColor​(K key)
        Using the other methods in this interface, retrieve a Color value from this dictionary; returning null if the key does not exist.
        Parameters:
        key - The key for the (supposed) Color value to retrieve.
        Returns:
        The color value, or null if the key is not present.
      • getFont

        default java.awt.Font getFont​(K key)
        Using the other methods in this interface, retrieve a Font value from this dictionary; returning null if the key does not exist.
        Parameters:
        key - The key for the (supposed) Font value to retrieve.
        Returns:
        The font value, or null if the key is not present.
      • putAll

        default void putAll​(Map<K,​V> map)
        Put all the key/value pairs from the given map into this dictionary.
        Parameters:
        map - The other map to use.
      • copy

        default java.lang.Object copy​(K key,
                                      Dictionary<K,​V> source)
        Copy the value from one dictionary to this one.
        Parameters:
        key - Key for value to be copied.
        source - The source to copy from.
        Returns:
        The previous value in the target dictionary.