@SuppressWarnings("unchecked") // reading field populated by writeObject @GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); keyType = (Class<K>) stream.readObject(); setDelegates( WellBehavedMap.wrap(new EnumMap<K, V>(keyType)), new HashMap<V, K>(keyType.getEnumConstants().length * 3 / 2)); Serialization.populateMap(this, stream); }
@GwtIncompatible // java.io.ObjectOutputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); expectedValuesPerKey = DEFAULT_VALUES_PER_KEY; int distinctKeys = Serialization.readCount(stream); Map<K, Collection<V>> map = Maps.newHashMap(); setMap(map); Serialization.populateMultimap(this, stream, distinctKeys); }
/** * @serialData the {@code Class<E>} for the enum type, the number of distinct elements, the first * element, its count, the second element, its count, and so on */ @GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); @SuppressWarnings("unchecked") // reading data stored by writeObject Class<E> localType = (Class<E>) stream.readObject(); type = localType; enumConstants = type.getEnumConstants(); counts = new int[enumConstants.length]; Serialization.populateMultiset(this, stream); }
@GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int distinctElements = Serialization.readCount(stream); setBackingMap(Maps.<E, Count>newHashMap()); Serialization.populateMultiset(this, stream, distinctElements); }
@GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int size = Serialization.readCount(stream); init(16); // resist hostile attempts to allocate gratuitous heap Serialization.populateMap(this, stream, size); }
/** * @serialData the key class, number of entries, first key, first value, second key, second value, * and so on. */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeObject(keyType); Serialization.writeMap(this, stream); }
@GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeObject(type); Serialization.writeMultiset(this, stream); }
/** * @serialData number of distinct keys, and then for each distinct key: the key, the number of * values for that key, and the key's values */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeObject(valueComparator()); Serialization.writeMultimap(this, stream); }
@GwtIncompatible // java.io.ObjectInputStream @SuppressWarnings("unchecked") // reading data stored by writeObject private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); keyComparator = checkNotNull((Comparator<? super K>) stream.readObject()); valueComparator = checkNotNull((Comparator<? super V>) stream.readObject()); setMap(new TreeMap<K, Collection<V>>(keyComparator)); Serialization.populateMultimap(this, stream); }
/** * @serialData the key class, number of entries, first key, first value, * second key, second value, and so on. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeObject(keyType); Serialization.writeMap(this, stream); }
@GwtIncompatible("java.io.ObjectInputStream") private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); expectedValuesPerKey = stream.readInt(); int distinctKeys = Serialization.readCount(stream); Map<K, Collection<V>> map = Maps.newHashMapWithExpectedSize(distinctKeys); setMap(map); Serialization.populateMultimap(this, stream, distinctKeys); }
/** * @serialData expectedValuesPerKey, number of distinct keys, and then for each distinct key: the * key, number of values for that key, and the key's values */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); Serialization.writeMultimap(this, stream); }
/** * @serialData the number of distinct elements, the first element, its count, the second element, * its count, and so on */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); Serialization.writeMultiset(this, stream); }
/** * @serialData the number of entries, first key, first value, second key, second value, and so on. */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); Serialization.writeMap(this, stream); }
/** * Populates a map by reading an input stream, as part of deserialization. See {@link #writeMap} * for the data format. */ static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream) throws IOException, ClassNotFoundException { int size = stream.readInt(); populateMap(map, stream, size); }
/** * Populates a multiset by reading an input stream, as part of deserialization. See {@link * #writeMultiset} for the data format. */ static <E> void populateMultiset(Multiset<E> multiset, ObjectInputStream stream) throws IOException, ClassNotFoundException { int distinctElements = stream.readInt(); populateMultiset(multiset, stream, distinctElements); }
/** * Populates a multimap by reading an input stream, as part of deserialization. See {@link * #writeMultimap} for the data format. */ static <K, V> void populateMultimap(Multimap<K, V> multimap, ObjectInputStream stream) throws IOException, ClassNotFoundException { int distinctKeys = stream.readInt(); populateMultimap(multimap, stream, distinctKeys); }
/** * @serialData the number of distinct elements, the first element, its count, * the second element, its count, and so on */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); // creating HashMultiset to handle concurrent changes Serialization.writeMultiset(HashMultiset.create(this), stream); }
@GwtIncompatible // java serialization is not supported static class FieldSettersHolder { static final Serialization.FieldSetter<ImmutableMultimap> MAP_FIELD_SETTER = Serialization.getFieldSetter(ImmutableMultimap.class, "map"); static final Serialization.FieldSetter<ImmutableMultimap> SIZE_FIELD_SETTER = Serialization.getFieldSetter(ImmutableMultimap.class, "size"); }
static class FieldSettersHolder { // Eclipse doesn't like the raw ImmutableMultimap @SuppressWarnings("unchecked") static final Serialization.FieldSetter<ImmutableMultimap> MAP_FIELD_SETTER = Serialization.getFieldSetter( ImmutableMultimap.class, "map"); // Eclipse doesn't like the raw ImmutableMultimap @SuppressWarnings("unchecked") static final Serialization.FieldSetter<ImmutableMultimap> SIZE_FIELD_SETTER = Serialization.getFieldSetter( ImmutableMultimap.class, "size"); }