Interface Association<K,V>

Type Parameters:
K - the type of the Key
V - the type of the Value
All Superinterfaces:
Assortment<Association.Entry<K,V>>, Countable, Enumerable<Association.Entry<K,V>>, Iterable<Association.Entry<K,V>>
All Known Subinterfaces:
EditableAssociation<K,V>, ResizableAssociation<K,V>

public interface Association<K,V> extends Assortment<Association.Entry<K,V>>
An Assortment of Association.Entry<K,V> that allows for retrieval of the values associated with the keys.
  • Method Details

    • builder

      static AssociationBuilder builder()
      .
      Returns:
      the builder
    • containsKey

      boolean containsKey(Object key)
      Determines if this Association contains the given key
      Parameters:
      key - the key to test
      Returns:
      true if the key is contained in the Association, false otherwise.
    • containsValue

      boolean containsValue(Object value)
      Determines if this Association contains the given key
      Parameters:
      value - the value to test
      Returns:
      true if the key is contained in the Association, false otherwise.
    • union

      Association<K,V> union(Association<K,V> other, BiFunction<V,V,V> valueSelector)
      Creates the union of this association with another. If the same key is found in both the function valueSelector is called to determine the result of the union.
      Parameters:
      other - the other association to union with.
      valueSelector - an operation to select the result of the union of two values
      Returns:
      a new Association with the union of the keys of the original Associations
    • intersection

      Association<K,V> intersection(Association<K,V> other, BiFunction<V,V,V> valueSelector)
      Creates the intersection of this association with another. When the same key is found in both the function valueSelector is called to determine the result of the union.
      Parameters:
      other - the other association to intersect with.
      valueSelector - an operation to select the result of the union of two values
      Returns:
      a new Association with the common keys in the original Associations
    • computeValueIfAbsent

      V computeValueIfAbsent(K key, Function<K,V> computation)
      If the value is found return it. If not, compute a value from the key. The computed value is not permanently associated with the key.
      Parameters:
      key -
      computation -
      Returns:
    • keys

      Returns keys.
      Returns:
      the result of keys
    • values

      Assortment<V> values()
      Returns values.
      Returns:
      the result of values
    • getValue

      Maybe<V> getValue(Object key)
      Returns get Value.
      Parameters:
      key - the key value
      Returns:
      the result of getValue
    • toCollection

      default Set<Association.Entry<K,V>> toCollection()
      Returns to Collection.
      Specified by:
      toCollection in interface Assortment<K>
      Returns:
      the result of toCollection