Created
November 10, 2015 20:05
-
-
Save mrmanc/8a290b9cf4d59964e8e0 to your computer and use it in GitHub Desktop.
ImmutableMap with mapOf()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
public abstract class ImmutableMap { | |
private ImmutableMap() {} | |
public static <K, V> Map<K, V> mapOf(K k1, V v1) { | |
return com.google.common.collect.ImmutableMap.of(k1, v1); | |
} | |
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2) { | |
return com.google.common.collect.ImmutableMap.of(k1, v1, k2, v2); | |
} | |
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3) { | |
return com.google.common.collect.ImmutableMap.of(k1, v1, k2, v2, k3, v3); | |
} | |
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) { | |
return com.google.common.collect.ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4); | |
} | |
public static <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) { | |
return com.google.common.collect.ImmutableMap.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5); | |
} | |
@Deprecated | |
public static <K, V> Map<K, V> of(K k1, V v1) { | |
return mapOf(k1, v1); | |
} | |
@Deprecated | |
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2) { | |
return mapOf(k1, v1, k2, v2); | |
} | |
@Deprecated | |
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) { | |
return mapOf(k1, v1, k2, v2, k3, v3); | |
} | |
@Deprecated | |
public static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) { | |
return mapOf(k1, v1, k2, v2, k3, v3, k4, v4); | |
} | |
@Deprecated | |
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) { | |
return mapOf(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment