From 177c4bd8f24ec81b2fe5cdfc486d82d74b2c1d28 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 26 Mar 2016 17:19:24 +0000 Subject: Remove ImmutableMap usage from MammothMaps --- .../zwobble/mammoth/internal/util/MammothMaps.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/zwobble/mammoth/internal/util/MammothMaps.java b/src/main/java/org/zwobble/mammoth/internal/util/MammothMaps.java index 269331f..1d8780c 100644 --- a/src/main/java/org/zwobble/mammoth/internal/util/MammothMaps.java +++ b/src/main/java/org/zwobble/mammoth/internal/util/MammothMaps.java @@ -1,7 +1,5 @@ package org.zwobble.mammoth.internal.util; -import com.google.common.collect.ImmutableMap; - import java.util.*; import java.util.function.Function; @@ -15,11 +13,18 @@ public class MammothMaps { } public static Map map(K key1, V value1, K key2, V value2) { - return ImmutableMap.of(key1, value1, key2, value2); + Map map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + return map; } public static Map map(K key1, V value1, K key2, V value2, K key3, V value3) { - return ImmutableMap.of(key1, value1, key2, value2, key3, value3); + Map map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + map.put(key3, value3); + return map; } public static Map.Entry entry(K key, V value) { @@ -35,11 +40,12 @@ public class MammothMaps { } public static Map toMap(Iterable iterable, Function> function) { - ImmutableMap.Builder builder = ImmutableMap.builder(); + Map map = new HashMap<>(); for (T element : iterable) { - builder.put(function.apply(element)); + Map.Entry entry = function.apply(element); + map.put(entry.getKey(), entry.getValue()); } - return builder.build(); + return map; } public static Map> toMultiMapWithKey(Iterable iterable, Function function) { -- cgit v1.2.3