@Test public void immutableList() { ImmutableListMultimap<Integer, Integer> empty = Multimaps.immutable.list.of(); ImmutableListMultimap<Integer, Integer> emptyWith = Multimaps.immutable.list.with(); Verify.assertEmpty(empty); Verify.assertEmpty(emptyWith); ImmutableListMultimap<Integer, Integer> one = Multimaps.immutable.list.of(1, 1); Assert.assertEquals(FastListMultimap.newMultimap(Tuples.pair(1, 1)), one); ImmutableListMultimap<Integer, Integer> two = Multimaps.immutable.list.of(1, 1, 2, 2); Assert.assertEquals(FastListMultimap.newMultimap(Tuples.pair(1, 1), Tuples.pair(2, 2)), two); ImmutableListMultimap<Integer, Integer> three = Multimaps.immutable.list.of(1, 1, 2, 2, 3, 3); Assert.assertEquals( FastListMultimap.newMultimap(Tuples.pair(1, 1), Tuples.pair(2, 2), Tuples.pair(3, 3)), three); }
@Test public void get() { MutableListMultimap<String, String> multimap = FastListMultimap.newMultimap(); multimap.putAll("One", FastList.newListWith("O", "N", "E")); multimap.putAll("Two", FastList.newListWith("T", "W", "O")); multimap.putAll("Three", FastList.newListWith("T", "H", "R", "E", "E")); Function<String, RichIterable<String>> getFunction = MultimapFunctions.get(multimap); Assert.assertEquals( FastList.newListWith( FastList.newListWith("O", "N", "E"), FastList.newListWith("T", "W", "O"), FastList.newListWith("T", "H", "R", "E", "E")), FastList.newListWith("One", "Two", "Three").collect(getFunction)); }
@Override public <V2> ImmutableListMultimap<K, V2> collectValues( Function<? super V, ? extends V2> function) { return this.collectValues(function, FastListMultimap.<K, V2>newMultimap()).toImmutable(); }