Interface CrudMapAdapter<Key,​Value>

  • Type Parameters:
    Key - Type of the keys
    Value - Type of the values associated with the keys.
    All Known Implementing Classes:
    CrudMapAdapter.Immutable, CrudMapAdapter.SetLike, CrudMapAdapter.SetLike.Immutable

    public interface CrudMapAdapter<Key,​Value>
    CRUD = create, read, update, and delete

    A data adapter with operations for adding, reading, updating, and deleting values indexed by a key.

    Since:
    8.2.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • computeSize

        default int computeSize()
        Gets the number of values associated with a key.

        The default implementation iterates through each candidate key and checks which keys are associated with a value.

        Returns:
        The number of existing key-value pairs.
      • delete

        void delete​(Key key)
        Removes the mapping for the given key.
        Parameters:
        key - Key to disassociate with any values.
      • enumerateCandidateKeys

        Iterable<Key> enumerateCandidateKeys()
        Enumerates all keys for which a mapping may be present. May include additional keys for which no value is available, see computeSize(). Must NOT contain duplicate keys.
        Returns:
        A set with all potential keys.
      • get

        Value get​(Key key)
        Gets the value for the given key. Returns null when no value is available for the key.
        Parameters:
        key - Key to access.
        Returns:
        The value associated with the key, or null when no value is associated with the key.
      • isEmpty

        default boolean isEmpty()
        Checks whether any keys are associated with a value.

        The default implementation iterates through each candidate key and checks if any key is associated with a value.

        Returns:
        true if no keys are associated with a value.
      • set

        void set​(Key key,
                 Value value)
        Associates a value with the given key.
        Parameters:
        key - Key to associate with a different value.
        value - Value to associate with the key, never null.