Class InfinispanCollections


  • public final class InfinispanCollections
    extends java.lang.Object
    Static helpers for Infinispan-specific collections
    Since:
    4.0
    Author:
    Manik Surtani
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertNotNullEntries​(java.util.Collection<?> collection, java.lang.String name)  
      static void assertNotNullEntries​(java.util.Map<?,​?> map, java.lang.String name)  
      static <T> boolean containsAny​(java.util.Collection<T> haystack, java.util.Collection<T> needles)  
      static <E> java.util.Set<E> difference​(java.util.Set<? extends E> s1, java.util.Set<? extends E> s2)
      Returns the elements that are present in s1 but which are not present in s2, without changing the contents of neither s1, nor s2.
      static <T> void forEach​(T[] array, java.util.function.Consumer<T> consumer)  
      static <T> java.util.List<T> mergeLists​(java.util.List<T> one, java.util.List<T> second)  
      static <K,​V>
      java.util.Map<K,​V>
      mergeMaps​(java.util.Map<K,​V> one, java.util.Map<K,​V> second)  
      static java.util.Set<java.lang.Object> toObjectSet​(java.util.Collection<?> collection)  
      static <K,​V,​E>
      java.util.Map<K,​V>
      transformCollectionToMap​(java.util.Collection<? extends E> input, InfinispanCollections.MapMakerFunction<K,​V,​? super E> f)
      Given a collection, transforms the collection to a map given a InfinispanCollections.MapMakerFunction
      static <K,​V,​E>
      java.util.Map<K,​V>
      transformMapValue​(java.util.Map<K,​E> input, InfinispanCollections.Function<E,​V> f)
      Given a map of well known key/value types, it makes a shallow copy of it while at the same time transforming it's value type to a desired output type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • transformMapValue

        public static <K,​V,​E> java.util.Map<K,​V> transformMapValue​(java.util.Map<K,​E> input,
                                                                                     InfinispanCollections.Function<E,​V> f)
        Given a map of well known key/value types, it makes a shallow copy of it while at the same time transforming it's value type to a desired output type. The transformation of the value type is done using a given a function.
        Type Parameters:
        K - input map's key type
        V - desired output type of the map's value
        E - input map's value type
        Parameters:
        input - contains the input key/value pair map
        f - function instance to use to transform the value part of the map
        Returns:
        a shallow copy of the input Map with all its values transformed.
      • transformCollectionToMap

        public static <K,​V,​E> java.util.Map<K,​V> transformCollectionToMap​(java.util.Collection<? extends E> input,
                                                                                            InfinispanCollections.MapMakerFunction<K,​V,​? super E> f)
        Given a collection, transforms the collection to a map given a InfinispanCollections.MapMakerFunction
        Type Parameters:
        K - output map's key type
        V - output type of the map's value
        E - input collection's entry type
        Parameters:
        input - contains a collection of type E
        f - MapMakerFunction instance to use to transform the collection to a key/value pair
        Returns:
        a Map with keys and values generated from the input collection
      • difference

        public static <E> java.util.Set<E> difference​(java.util.Set<? extends E> s1,
                                                      java.util.Set<? extends E> s2)
        Returns the elements that are present in s1 but which are not present in s2, without changing the contents of neither s1, nor s2.
        Type Parameters:
        E - type of objects in Set
        Parameters:
        s1 - first set
        s2 - second set
        Returns:
        the elements in s1 that are not in s2
      • containsAny

        public static <T> boolean containsAny​(java.util.Collection<T> haystack,
                                              java.util.Collection<T> needles)
      • forEach

        public static <T> void forEach​(T[] array,
                                       java.util.function.Consumer<T> consumer)
      • assertNotNullEntries

        public static void assertNotNullEntries​(java.util.Map<?,​?> map,
                                                java.lang.String name)
      • assertNotNullEntries

        public static void assertNotNullEntries​(java.util.Collection<?> collection,
                                                java.lang.String name)
      • mergeMaps

        public static <K,​V> java.util.Map<K,​V> mergeMaps​(java.util.Map<K,​V> one,
                                                                     java.util.Map<K,​V> second)
      • mergeLists

        public static <T> java.util.List<T> mergeLists​(java.util.List<T> one,
                                                       java.util.List<T> second)
      • toObjectSet

        public static java.util.Set<java.lang.Object> toObjectSet​(java.util.Collection<?> collection)