Class CollectionsFactory


  • public final class CollectionsFactory
    extends java.lang.Object
    Factory class used as an accessor to Collections implementations.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> IDeltaBag<T> createDeltaBag()
      Instantiates a new empty delta bag.
      static <K,​V>
      java.util.Map<K,​V>
      createMap()
      Instantiates a new empty map.
      static <K,​V>
      java.util.Map<K,​V>
      createMap​(java.util.Map<K,​V> initial)
      Instantiates a new map with the given initial contents.
      static <T> IMemory<T> createMemory​(java.lang.Class<? super T> values, CollectionsFactory.MemoryType memoryType)
      Instantiates a memory storing values.
      static <K,​V>
      IMultiLookup<K,​V>
      createMultiLookup​(java.lang.Class<? super K> fromKeys, CollectionsFactory.MemoryType toBuckets, java.lang.Class<? super V> ofValues)
      Instantiates a size-optimized multimap from keys to sets of values.
      static <T> IMultiset<T> createMultiset()
      Instantiates a new empty multiset.
      static <O> java.util.List<O> createObserverList()
      Instantiates a new list that is optimized for registering observers / callbacks.
      static <E> java.util.Set<E> createSet()
      Instantiates a new empty set.
      static <E> java.util.Set<E> createSet​(java.util.Collection<E> initial)
      Instantiates a new set with the given initial contents.
      static <K,​V>
      java.util.TreeMap<K,​V>
      createTreeMap()
      Instantiates a new tree map.
      static <T> IMultiset<T> emptyMultiset​(java.lang.Object key)
      Instantiates an empty multiset; the key parameter is used to allow using this as a method reference as a Function, e.g.
      static <T> java.util.Set<T> emptySet​(java.lang.Object key)
      Instantiates an empty set; the key parameter is used to allow using this as a method reference as a Function, e.g.
      • Methods inherited from class java.lang.Object

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

      • CollectionsFactory

        public CollectionsFactory()
    • Method Detail

      • createMap

        public static <K,​V> java.util.Map<K,​V> createMap()
        Instantiates a new empty map.
        Since:
        1.7
      • createMap

        public static <K,​V> java.util.Map<K,​V> createMap​(java.util.Map<K,​V> initial)
        Instantiates a new map with the given initial contents.
        Since:
        1.7
      • createTreeMap

        public static <K,​V> java.util.TreeMap<K,​V> createTreeMap()
        Instantiates a new tree map.
        Since:
        2.3
      • createSet

        public static <E> java.util.Set<E> createSet()
        Instantiates a new empty set.
        Since:
        1.7
      • createSet

        public static <E> java.util.Set<E> createSet​(java.util.Collection<E> initial)
        Instantiates a new set with the given initial contents.
        Since:
        1.7
      • emptySet

        public static <T> java.util.Set<T> emptySet​(java.lang.Object key)
        Instantiates an empty set; the key parameter is used to allow using this as a method reference as a Function, e.g. in Map.computeIfAbsent(Object, Function).
        Parameters:
        key - the value of this parameter is ignored
        Since:
        2.0
      • createMultiset

        public static <T> IMultiset<T> createMultiset()
        Instantiates a new empty multiset.
        Since:
        1.7
      • emptyMultiset

        public static <T> IMultiset<T> emptyMultiset​(java.lang.Object key)
        Instantiates an empty multiset; the key parameter is used to allow using this as a method reference as a Function, e.g. in Map.computeIfAbsent(Object, Function).
        Parameters:
        key - the value of this parameter is ignored
        Since:
        2.0
      • createDeltaBag

        public static <T> IDeltaBag<T> createDeltaBag()
        Instantiates a new empty delta bag.
        Since:
        1.7
      • createObserverList

        public static <O> java.util.List<O> createObserverList()
        Instantiates a new list that is optimized for registering observers / callbacks.
        Since:
        1.7
      • createMultiLookup

        public static <K,​V> IMultiLookup<K,​V> createMultiLookup​(java.lang.Class<? super K> fromKeys,
                                                                            CollectionsFactory.MemoryType toBuckets,
                                                                            java.lang.Class<? super V> ofValues)
        Instantiates a size-optimized multimap from keys to sets of values.

        For a single key, many values can be associated according to the given bucket semantics.

        The keys and values are stored as type fromKeys resp. ofValues; currently Object.class and Long.class are supported.

        Since:
        2.0
      • createMemory

        public static <T> IMemory<T> createMemory​(java.lang.Class<? super T> values,
                                                  CollectionsFactory.MemoryType memoryType)
        Instantiates a memory storing values.

        For a single key, many values can be associated according to the given memory semantics.

        The values are stored as type 'values'; currently Object.class and Long.class are supported.

        Since:
        2.0