/** * @serialData the number of distinct keys, and then for each distinct key: the first key, the * number of values for that key, and the key's values, followed by successive keys and values * from the entries() ordering */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(size()); for (Entry<K, V> entry : entries()) { stream.writeObject(entry.getKey()); stream.writeObject(entry.getValue()); } }
@Override protected void verify(List<Entry<String, Integer>> elements) { assertEquals(elements, multimap.entries()); } }.test();
public static void serialize(SerializationStreamWriter out, LinkedListMultimap<?, ?> multimap) throws SerializationException { out.writeInt(multimap.size()); for (Entry<?, ?> entry : multimap.entries()) { out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } } }
/** * @serialData the number of distinct keys, and then for each distinct key: the first key, the * number of values for that key, and the key's values, followed by successive keys and values * from the entries() ordering */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(size()); for (Entry<K, V> entry : entries()) { stream.writeObject(entry.getKey()); stream.writeObject(entry.getValue()); } }
public void testCreateFromMultimap() { Multimap<String, Integer> multimap = LinkedListMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 3); multimap.put("foo", 2); LinkedListMultimap<String, Integer> copy = LinkedListMultimap.create(multimap); assertEquals(multimap, copy); assertThat(copy.entries()).containsExactlyElementsIn(multimap.entries()).inOrder(); }
@Override protected ListIterator<Entry<String, Integer>> newTargetIterator() { multimap = create(); multimap.putAll("foo", asList(2, 3)); multimap.putAll("bar", asList(4, 5)); multimap.put("foo", 6); return multimap.entries().listIterator(startIndex); }
public void testLinkedGetAdd() { LinkedListMultimap<String, Integer> map = create(); map.put("bar", 1); Collection<Integer> foos = map.get("foo"); foos.add(2); foos.add(3); map.put("bar", 4); map.put("foo", 5); assertEquals("{bar=[1, 4], foo=[2, 3, 5]}", map.toString()); assertEquals("[bar=1, foo=2, foo=3, bar=4, foo=5]", map.entries().toString()); }
/** * @serialData the number of distinct keys, and then for each distinct key: * the first key, the number of values for that key, and the key's values, * followed by successive keys and values from the entries() ordering */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(size()); for (Entry<K, V> entry : entries()) { stream.writeObject(entry.getKey()); stream.writeObject(entry.getValue()); } }
@Override public String asHtml() { String resultStr = ""; for (Map.Entry<String, DiffResult> result: innerResults.entries()) { resultStr += result.getValue().asHtml(result.getKey() + ": ", "", "") + "\n"; } return resultStr; }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
@Override public String asHtml(String key, String indent, String delimiter) { String resultStr = indent + key; for (Map.Entry<String, DiffResult> result: innerResults.entries()) { resultStr += "\n" + result.getValue().asHtml(result.getKey() + ": ", indent + " ", ""); } return resultStr + delimiter; }
@Override public String asConsole() { String resultStr = ""; for (Map.Entry<String, DiffResult> result: innerResults.entries()) { resultStr += RESET + result.getValue().asConsole(result.getKey() + ": ", " ", "") + "\n"; } return resultStr + RESET; }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
@Override public String asConsole(String key, String indent, String delimiter) { String resultStr = indent + key; for (Map.Entry<String, DiffResult> result: innerResults.entries()) { resultStr += "\n" + RESET + result.getValue().asConsole(result.getKey() + ": ", indent + " ", ""); } return resultStr + delimiter + RESET; }
public void save() throws IOException { if (file != null) { file.getAbsoluteFile().getParentFile().mkdirs(); String data = Joiner.on('\n').withKeyValueSeparator(" = ").useForNull("").join(configuration.entries()) + "\n"; Files.write(data, file, Charsets.UTF_8); } }
@Override protected void verify(List<Entry<String, Integer>> elements) { assertEquals(elements, multimap.entries()); } }.test();
public static void serialize(SerializationStreamWriter out, LinkedListMultimap<?, ?> multimap) throws SerializationException { out.writeInt(multimap.size()); for (Entry<?, ?> entry : multimap.entries()) { out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } } }
public void testCreateFromMultimap() { Multimap<String, Integer> multimap = LinkedListMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 3); multimap.put("foo", 2); LinkedListMultimap<String, Integer> copy = LinkedListMultimap.create(multimap); assertEquals(multimap, copy); assertThat(copy.entries()).containsExactlyElementsIn(multimap.entries()).inOrder(); }
@Override protected ListIterator<Entry<String, Integer>> newTargetIterator() { multimap = create(); multimap.putAll("foo", asList(2, 3)); multimap.putAll("bar", asList(4, 5)); multimap.put("foo", 6); return multimap.entries().listIterator(startIndex); }
public void testLinkedGetAdd() { LinkedListMultimap<String, Integer> map = create(); map.put("bar", 1); Collection<Integer> foos = map.get("foo"); foos.add(2); foos.add(3); map.put("bar", 4); map.put("foo", 5); assertEquals("{bar=[1, 4], foo=[2, 3, 5]}", map.toString()); assertEquals("[bar=1, foo=2, foo=3, bar=4, foo=5]", map.entries().toString()); }