Interface MapWrapper<K,​V>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void addAll​(Iterable<? extends V> iterable)
      add all elements of iterable
      void clear()
      Clear all entries from map
      boolean containsValue​(V value)
      Check if value is already present
      V firstMatch​(Predicate<V> valuePredicate)
      Find first entry that matches the predicate
      static <KK,​VV>
      VV
      firstMatch​(MapWrapper<KK,​VV> mapWrapper, Predicate<VV> valuePredicate)
      Collect first match by iterating through map based on some predicate
      default <T extends V>
      void
      forEachIn​(Collection<T> values, Consumer<T> consumer)
      apply provided consumer to each element in values as long as that element is registered on this wrapper
      V get​(K key)
      Collect entry from container
      default V getFirst()
      collect the first entry based on the iterator's result, which is not necessarily the fist entry ordered by the key, it is just the first entry the iterator would provide
      K getKeyByValue​(V value)
      collect the key used for the given value
      boolean isEmpty()
      Verify if the map is empty
      V register​(V value)
      Register on the internal container (no null keys allowed which will trigger a warning and the value not to be registered)
      V remove​(V value)
      Remove value from map
      default void removeAll​(Collection<V> toBeRemoved)
      Remove all entries in provided collection.
      void removeIf​(Predicate<V> condition)
      Remove all values that satisfy the given condition
      MapWrapper<K,​V> shallowClone()
      Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created
      int size()
      The number of registered entries
      default Stream<V> stream()
      Create a stream from this iterable
      default <M extends Comparable>
      Stream<V>
      streamSorted​(Function<V,​M> comparingFunction)
      stream in a sorted manner to allow for a specific ordering other than the underlying key used
      Collection<V> toCollection()
      Collect values as unmodifiable collection
      default <K> Map<K,​V> toMap​(Function<V,​K> getCustomKey)
      Convert to a map with a custom key obtained from entries
      Set<V> valuesAsNewSet()
      Create a copy of the map's distinct values as a set
    • Method Detail

      • firstMatch

        static <KK,​VV> VV firstMatch​(MapWrapper<KK,​VV> mapWrapper,
                                           Predicate<VV> valuePredicate)
        Collect first match by iterating through map based on some predicate
        Type Parameters:
        KK - key type
        VV - value type
        Parameters:
        mapWrapper - the wrapper to apply to
        valuePredicate - the filter to apply to obtain the first match
        Returns:
        found match
      • register

        V register​(V value)
        Register on the internal container (no null keys allowed which will trigger a warning and the value not to be registered)
        Parameters:
        value - to register
        Returns:
        old value if any
      • remove

        V remove​(V value)
        Remove value from map
        Parameters:
        value - to remove
        Returns:
        removed entry if any
      • removeAll

        default void removeAll​(Collection<V> toBeRemoved)
        Remove all entries in provided collection.
        Parameters:
        toBeRemoved - the to be removed entries
      • removeIf

        void removeIf​(Predicate<V> condition)
        Remove all values that satisfy the given condition
        Parameters:
        condition - to remove
      • clear

        void clear()
        Clear all entries from map
      • get

        V get​(K key)
        Collect entry from container
        Parameters:
        key - to use
        Returns:
        value for key
      • size

        int size()
        The number of registered entries
        Returns:
        number of entries
      • isEmpty

        boolean isEmpty()
        Verify if the map is empty
        Returns:
        true when empty false otherwise
      • containsValue

        boolean containsValue​(V value)
        Check if value is already present
        Parameters:
        value - to verify
        Returns:
        true if present, false otherwise
      • toCollection

        Collection<V> toCollection()
        Collect values as unmodifiable collection
        Returns:
        collection
      • valuesAsNewSet

        Set<V> valuesAsNewSet()
        Create a copy of the map's distinct values as a set
        Returns:
        copy of values as set
      • firstMatch

        V firstMatch​(Predicate<V> valuePredicate)
        Find first entry that matches the predicate
        Parameters:
        valuePredicate - that checks a property of the value and the first which matches is returned
        Returns:
        the retrieved entry, or null if no traveler type was found
      • shallowClone

        MapWrapper<K,​V> shallowClone()
        Each map wrapper should be cloneable where the contents are references of the original where possible but the underlying map itself is newly created
        Returns:
        copy
      • getKeyByValue

        K getKeyByValue​(V value)
        collect the key used for the given value
        Parameters:
        value - to collect used key for
        Returns:
        key
      • getFirst

        default V getFirst()
        collect the first entry based on the iterator's result, which is not necessarily the fist entry ordered by the key, it is just the first entry the iterator would provide
        Returns:
        first iterable entry, null if empty
      • addAll

        default void addAll​(Iterable<? extends V> iterable)
        add all elements of iterable
        Parameters:
        iterable - to add elements of
      • forEachIn

        default <T extends V> void forEachIn​(Collection<T> values,
                                             Consumer<T> consumer)
        apply provided consumer to each element in values as long as that element is registered on this wrapper
        Type Parameters:
        T - type of values
        Parameters:
        values - to apply consumer to when they are registered in this wrapper
        consumer - to apply
      • toMap

        default <K> Map<K,​V> toMap​(Function<V,​K> getCustomKey)
        Convert to a map with a custom key obtained from entries
        Type Parameters:
        K - type of key
        Parameters:
        getCustomKey - function to extract key from entries
        Returns:
        populated map
      • stream

        default Stream<V> stream()
        Create a stream from this iterable
        Returns:
        stream of all entries (values)
      • streamSorted

        default <M extends ComparableStream<V> streamSorted​(Function<V,​M> comparingFunction)
        stream in a sorted manner to allow for a specific ordering other than the underlying key used
        Type Parameters:
        M - type of comparable
        Parameters:
        comparingFunction - to apply to sorted stream
        Returns:
        stream of all entries (values) ordered by given comparing function