Package graphql.util
Class LinkedHashMapFactory
java.lang.Object
graphql.util.LinkedHashMapFactory
Factory class for creating LinkedHashMap instances with insertion order preservation.
Use this instead of Map.of() to ensure consistent serialization order.
This class provides static factory methods similar to Map.of() but returns mutable LinkedHashMap instances that preserve insertion order, which is important for consistent serialization.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Map <K, V> of()
Returns an empty LinkedHashMap.static <K,
V> Map <K, V> of
(K k1, V v1) Returns a LinkedHashMap containing a single mapping.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2) Returns a LinkedHashMap containing two mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3) Returns a LinkedHashMap containing three mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) Returns a LinkedHashMap containing four mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) Returns a LinkedHashMap containing five mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Returns a LinkedHashMap containing six mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Returns a LinkedHashMap containing seven mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Returns a LinkedHashMap containing eight mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Returns a LinkedHashMap containing nine mappings.static <K,
V> Map <K, V> of
(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Returns a LinkedHashMap containing ten mappings.static <K,
V> Map <K, V> Returns a LinkedHashMap containing mappings derived from the given arguments.
-
Method Details
-
of
Returns an empty LinkedHashMap.- Type Parameters:
K
- the key typeV
- the value type- Returns:
- an empty LinkedHashMap
-
of
Returns a LinkedHashMap containing a single mapping.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the mapping's keyv1
- the mapping's value- Returns:
- a LinkedHashMap containing the specified mapping
-
of
Returns a LinkedHashMap containing two mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
Returns a LinkedHashMap containing three mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
Returns a LinkedHashMap containing four mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
Returns a LinkedHashMap containing five mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
public static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Returns a LinkedHashMap containing six mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's valuek6
- the sixth mapping's keyv6
- the sixth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
public static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Returns a LinkedHashMap containing seven mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's valuek6
- the sixth mapping's keyv6
- the sixth mapping's valuek7
- the seventh mapping's keyv7
- the seventh mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
public static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Returns a LinkedHashMap containing eight mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's valuek6
- the sixth mapping's keyv6
- the sixth mapping's valuek7
- the seventh mapping's keyv7
- the seventh mapping's valuek8
- the eighth mapping's keyv8
- the eighth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
public static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Returns a LinkedHashMap containing nine mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's valuek6
- the sixth mapping's keyv6
- the sixth mapping's valuek7
- the seventh mapping's keyv7
- the seventh mapping's valuek8
- the eighth mapping's keyv8
- the eighth mapping's valuek9
- the ninth mapping's keyv9
- the ninth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
of
public static <K,V> Map<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Returns a LinkedHashMap containing ten mappings.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
k1
- the first mapping's keyv1
- the first mapping's valuek2
- the second mapping's keyv2
- the second mapping's valuek3
- the third mapping's keyv3
- the third mapping's valuek4
- the fourth mapping's keyv4
- the fourth mapping's valuek5
- the fifth mapping's keyv5
- the fifth mapping's valuek6
- the sixth mapping's keyv6
- the sixth mapping's valuek7
- the seventh mapping's keyv7
- the seventh mapping's valuek8
- the eighth mapping's keyv8
- the eighth mapping's valuek9
- the ninth mapping's keyv9
- the ninth mapping's valuek10
- the tenth mapping's keyv10
- the tenth mapping's value- Returns:
- a LinkedHashMap containing the specified mappings
-
ofEntries
Returns a LinkedHashMap containing mappings derived from the given arguments.This method is provided for cases where more than 10 key-value pairs are needed. It accepts alternating keys and values.
- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keyValues
- alternating keys and values- Returns:
- a LinkedHashMap containing the specified mappings
- Throws:
IllegalArgumentException
- if an odd number of arguments is provided
-