Class MapFactory


  • public final class MapFactory
    extends java.lang.Object
    The factory class MapFactory provides factory methods for create new Map objects
    • Constructor Summary

      Constructors 
      Constructor Description
      MapFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.Integer,​java.util.Map<java.lang.String,​java.lang.String>> newAssosiativeArrayMap()
      Factory method for Map that acts like a javascript associative array.
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      newConcurrentHashMap()
      Factory method for create a new ConcurrentHashMap
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      newConcurrentHashMap​(int initialCapacity)
      Factory method for create a new ConcurrentHashMap
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      newConcurrentHashMap​(@NonNull java.util.Map<K,​V> map)
      Factory method for create a new ConcurrentHashMap
      static <K> java.util.Map<K,​java.lang.Integer> newCounterMap​(@NonNull java.util.Collection<K> elements)
      Factory method for create a map for counting elements of the given collection
      static <K,​V>
      java.util.Map<K,​V>
      newHashMap()
      Factory method for create a new HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newHashMap​(int initialCapacity)
      Factory method for create a new HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newHashMap​(@NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
      Factory method for create a new HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newHashMap​(@NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
      Factory method for create a new HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newHashMap​(@NonNull java.util.Map<K,​V> map)
      Factory method for create a new HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newInsertionOrderMap()
      Factory method for create a new InsertionOrderMap
      static <K,​V>
      java.util.Map<K,​V>
      newInsertionOrderMap​(int initialCapacity)
      Factory method for create a new InsertionOrderMap
      static <K,​V>
      java.util.Map<K,​V>
      newInsertionOrderMap​(@NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
      Factory method for create a new InsertionOrderMap
      static <K,​V>
      java.util.Map<K,​V>
      newInsertionOrderMap​(@NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
      Factory method for create a new InsertionOrderMap
      static <K,​V>
      java.util.Map<K,​V>
      newInsertionOrderMap​(@NonNull java.util.Map<K,​V> map)
      Factory method for create a new InsertionOrderMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyHashMap()
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyHashMap​(java.util.HashMap<K,​V> map)
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyMap()
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyTreeMap()
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyTreeMap​(@NonNull java.util.Comparator<? super K> comparator)
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newLazyTreeMap​(@NonNull java.util.TreeMap<K,​V> map)
      Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMap()
      Factory method for create a new LinkedHashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMap​(int initialCapacity)
      Factory method for create a new LinkedHashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMap​(@NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
      Factory method for create a new LinkedHashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMap​(@NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
      Factory method for create a new LinkedHashMap
      static <K,​V>
      java.util.Map<K,​V>
      newLinkedHashMap​(@NonNull java.util.Map<K,​V> map)
      Factory method for create a new LinkedHashMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap()
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull java.util.Comparator<? super K> comparator)
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull java.util.Comparator<? super K> comparator, @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull java.util.Comparator<? super K> comparator, @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
      Factory method for create a new TreeMap
      static <K,​V>
      java.util.Map<K,​V>
      newTreeMap​(@NonNull java.util.Map<K,​V> map)
      Factory method for create a new TreeMap
      • Methods inherited from class java.lang.Object

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

      • MapFactory

        public MapFactory()
    • Method Detail

      • newCounterMap

        public static <K> java.util.Map<K,​java.lang.Integer> newCounterMap​(@NonNull
                                                                                 @NonNull java.util.Collection<K> elements)
        Factory method for create a map for counting elements of the given collection
        Type Parameters:
        K - the generic type of the elements
        Parameters:
        elements - the elements
        Returns:
        the new map ready to count elements
      • newInsertionOrderMap

        public static <K,​V> java.util.Map<K,​V> newInsertionOrderMap()
        Factory method for create a new InsertionOrderMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new InsertionOrderMap
      • newInsertionOrderMap

        public static <K,​V> java.util.Map<K,​V> newInsertionOrderMap​(int initialCapacity)
        Factory method for create a new InsertionOrderMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        initialCapacity - the initial capacity
        Returns:
        The new InsertionOrderMap
      • newInsertionOrderMap

        public static <K,​V> java.util.Map<K,​V> newInsertionOrderMap​(@NonNull
                                                                                @NonNull java.util.Map<K,​V> map)
        Factory method for create a new InsertionOrderMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new InsertionOrderMap
      • newInsertionOrderMap

        public static <K,​V> java.util.Map<K,​V> newInsertionOrderMap​(@NonNull
                                                                                @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
        Factory method for create a new InsertionOrderMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the collection with the key value pairs
        Returns:
        The new InsertionOrderMap
      • newInsertionOrderMap

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> newInsertionOrderMap​(@NonNull
                                                                                @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
        Factory method for create a new InsertionOrderMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the key value pairs to add in the new InsertionOrderMap
        Returns:
        The new InsertionOrderMap
      • newAssosiativeArrayMap

        public static java.util.Map<java.lang.Integer,​java.util.Map<java.lang.String,​java.lang.String>> newAssosiativeArrayMap()
        Factory method for Map that acts like a javascript associative array. This Map is the counterpart for the associative array in js. For instance: in js you can create and fetch associative arrays like this:
         $arrayObj[0]['firstName'] = 'Albert';
         $arrayObj[0]['lastName'] = 'Einstein';
         $arrayObj[1]['firstName'] = 'Neil';
         $arrayObj[0]['lastName'] = 'Armstrong';
         
        With this method you can do the same like this:
         final Map<Integer, Map<String, String>> arrayMap = MapExtensions.newAssosiativeArrayMap();
        
         arrayMap.get(0).put("firstName", "Albert");
         arrayMap.get(0).put("lastName", "Einstein");
         arrayMap.get(1).put("firstName", "Neil");
         arrayMap.get(1).put("lastName", "Armstrong");
         
        Returns:
        The Map that acts like a javascript associative array
      • newConcurrentHashMap

        public static <K,​V> java.util.concurrent.ConcurrentHashMap<K,​V> newConcurrentHashMap()
        Factory method for create a new ConcurrentHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new ConcurrentHashMap
      • newConcurrentHashMap

        public static <K,​V> java.util.concurrent.ConcurrentHashMap<K,​V> newConcurrentHashMap​(@NonNull
                                                                                                         @NonNull java.util.Map<K,​V> map)
        Factory method for create a new ConcurrentHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new ConcurrentHashMap
      • newConcurrentHashMap

        public static <K,​V> java.util.concurrent.ConcurrentHashMap<K,​V> newConcurrentHashMap​(int initialCapacity)
        Factory method for create a new ConcurrentHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        initialCapacity - the initial capacity
        Returns:
        The new ConcurrentHashMap
      • newHashMap

        public static <K,​V> java.util.Map<K,​V> newHashMap​(int initialCapacity)
        Factory method for create a new HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        initialCapacity - the initial capacity
        Returns:
        The new HashMap
      • newHashMap

        public static <K,​V> java.util.Map<K,​V> newHashMap()
        Factory method for create a new HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new HashMap
      • newHashMap

        public static <K,​V> java.util.Map<K,​V> newHashMap​(@NonNull
                                                                      @NonNull java.util.Map<K,​V> map)
        Factory method for create a new HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new HashMap
      • newHashMap

        public static <K,​V> java.util.Map<K,​V> newHashMap​(@NonNull
                                                                      @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
        Factory method for create a new HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the collection with the key value pairs
        Returns:
        The new HashMap
      • newHashMap

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> newHashMap​(@NonNull
                                                                      @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
        Factory method for create a new HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the key value pairs to add in the new HashMap
        Returns:
        The new HashMap
      • newLinkedHashMap

        public static <K,​V> java.util.Map<K,​V> newLinkedHashMap()
        Factory method for create a new LinkedHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new LinkedHashMap
      • newLinkedHashMap

        public static <K,​V> java.util.Map<K,​V> newLinkedHashMap​(@NonNull
                                                                            @NonNull java.util.Map<K,​V> map)
        Factory method for create a new LinkedHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new LinkedHashMap
      • newLinkedHashMap

        public static <K,​V> java.util.Map<K,​V> newLinkedHashMap​(@NonNull
                                                                            @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
        Factory method for create a new LinkedHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the collection with the key value pairs
        Returns:
        The new LinkedHashMap
      • newLinkedHashMap

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> newLinkedHashMap​(@NonNull
                                                                            @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
        Factory method for create a new LinkedHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the key value pairs to add in the new LinkedHashMap
        Returns:
        The new LinkedHashMap
      • newLinkedHashMap

        public static <K,​V> java.util.Map<K,​V> newLinkedHashMap​(int initialCapacity)
        Factory method for create a new LinkedHashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        initialCapacity - the initial capacity
        Returns:
        The new LinkedHashMap
      • newLazyMap

        public static <K,​V> java.util.Map<K,​V> newLazyMap()
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new LazyMap
      • newLazyHashMap

        public static <K,​V> java.util.Map<K,​V> newLazyHashMap()
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new LazyMap
      • newLazyHashMap

        public static <K,​V> java.util.Map<K,​V> newLazyHashMap​(java.util.HashMap<K,​V> map)
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a HashMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map to initialize with it
        Returns:
        The new LazyMap
      • newLazyTreeMap

        public static <K,​V> java.util.Map<K,​V> newLazyTreeMap()
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new LazyMap
      • newLazyTreeMap

        public static <K,​V> java.util.Map<K,​V> newLazyTreeMap​(@NonNull
                                                                          @NonNull java.util.TreeMap<K,​V> map)
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new LazyMap
      • newLazyTreeMap

        public static <K,​V> java.util.Map<K,​V> newLazyTreeMap​(@NonNull
                                                                          @NonNull java.util.Comparator<? super K> comparator)
        Factory method for create a new LazyMap from commons-collections4 that encapsulates a TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        comparator - the comparator
        Returns:
        The new LazyMap
      • newTreeMap

        public static <K,​V> java.util.Map<K,​V> newTreeMap()
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Returns:
        The new TreeMap
      • newTreeMap

        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull java.util.Map<K,​V> map)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        map - the map
        Returns:
        The new TreeMap
      • newTreeMap

        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull java.util.Comparator<? super K> comparator)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        comparator - the comparator
        Returns:
        The new TreeMap
      • newTreeMap

        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull java.util.Comparator<? super K> comparator,
                                                                      @NonNull
                                                                      @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        comparator - the comparator
        keyValuePairs - the key value pairs
        Returns:
        The new TreeMap
      • newTreeMap

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull java.util.Comparator<? super K> comparator,
                                                                      @NonNull
                                                                      @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        comparator - the comparator
        keyValuePairs - the key value pairs to add in the new TreeMap
        Returns:
        The new TreeMap
      • newTreeMap

        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull java.util.Collection<de.alpharogroup.collections.pairs.KeyValuePair<K,​V>> keyValuePairs)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the collection with the key value pairs
        Returns:
        The new TreeMap
      • newTreeMap

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> newTreeMap​(@NonNull
                                                                      @NonNull de.alpharogroup.collections.pairs.KeyValuePair<K,​V>... keyValuePairs)
        Factory method for create a new TreeMap
        Type Parameters:
        K - the generic type of the key
        V - the generic type of the value
        Parameters:
        keyValuePairs - the key value pairs to add in the new TreeMap
        Returns:
        The new TreeMap