Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Fix for issue #67 - ImmutableSetMultimap ordering #68

Merged
merged 2 commits into from
Jun 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type,
}

if (ImmutableSetMultimap.class.isAssignableFrom(raw)) {
// TODO
// [Issue#67]: Preserve order of entries
return new LinkedHashMultimapDeserializer(type, keyDeserializer,
elementTypeDeserializer, elementDeserializer);
}
if (HashMultimap.class.isAssignableFrom(raw)) {
return new HashMultimapDeserializer(type, keyDeserializer, elementTypeDeserializer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.common.collect.*;

import java.io.IOException;
import java.util.Iterator;
import java.util.Map;

import static com.google.common.collect.TreeMultimap.create;
Expand Down Expand Up @@ -235,4 +236,21 @@ private ListMultimap<String, String> listBasedHelper(TypeReference<?> type) thro
assertTrue(map.containsEntry("second", "bar"));
return map;
}
}

public void testIssue67() throws IOException
{
ImmutableSetMultimap<String, Integer> map = MAPPER.readValue(
"{\"d\":[1,2],\"c\":[3,4],\"b\":[5,6],\"a\":[7,8]}",
new TypeReference<ImmutableSetMultimap<String, Integer>>() {});
assertEquals(8, map.size());
Iterator<Map.Entry<String, Integer>> iterator = map.entries().iterator();
assertEquals(Maps.immutableEntry("d", 1), iterator.next());
assertEquals(Maps.immutableEntry("d", 2), iterator.next());
assertEquals(Maps.immutableEntry("c", 3), iterator.next());
assertEquals(Maps.immutableEntry("c", 4), iterator.next());
assertEquals(Maps.immutableEntry("b", 5), iterator.next());
assertEquals(Maps.immutableEntry("b", 6), iterator.next());
assertEquals(Maps.immutableEntry("a", 7), iterator.next());
assertEquals(Maps.immutableEntry("a", 8), iterator.next());
}
}