117 lines
4.3 KiB
Java
117 lines
4.3 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.collect.Multiset;
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectOutputStream;
|
|
import java.lang.reflect.Field;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class Serialization {
|
|
|
|
static final class FieldSetter<T> {
|
|
private final Field a;
|
|
|
|
void a(T t, Object obj) {
|
|
try {
|
|
this.a.set(t, obj);
|
|
} catch (IllegalAccessException e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
|
|
private FieldSetter(Field field) {
|
|
this.a = field;
|
|
field.setAccessible(true);
|
|
}
|
|
|
|
void a(T t, int i) {
|
|
try {
|
|
this.a.set(t, Integer.valueOf(i));
|
|
} catch (IllegalAccessException e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
static int a(ObjectInputStream objectInputStream) throws IOException {
|
|
return objectInputStream.readInt();
|
|
}
|
|
|
|
static <K, V> void a(Map<K, V> map, ObjectOutputStream objectOutputStream) throws IOException {
|
|
objectOutputStream.writeInt(map.size());
|
|
for (Map.Entry<K, V> entry : map.entrySet()) {
|
|
objectOutputStream.writeObject(entry.getKey());
|
|
objectOutputStream.writeObject(entry.getValue());
|
|
}
|
|
}
|
|
|
|
static <K, V> void a(Map<K, V> map, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
|
a(map, objectInputStream, objectInputStream.readInt());
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
static <K, V> void a(Map<K, V> map, ObjectInputStream objectInputStream, int i) throws IOException, ClassNotFoundException {
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
map.put(objectInputStream.readObject(), objectInputStream.readObject());
|
|
}
|
|
}
|
|
|
|
static <E> void a(Multiset<E> multiset, ObjectOutputStream objectOutputStream) throws IOException {
|
|
objectOutputStream.writeInt(multiset.entrySet().size());
|
|
for (Multiset.Entry<E> entry : multiset.entrySet()) {
|
|
objectOutputStream.writeObject(entry.a());
|
|
objectOutputStream.writeInt(entry.getCount());
|
|
}
|
|
}
|
|
|
|
static <E> void a(Multiset<E> multiset, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
|
a(multiset, objectInputStream, objectInputStream.readInt());
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
static <E> void a(Multiset<E> multiset, ObjectInputStream objectInputStream, int i) throws IOException, ClassNotFoundException {
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
multiset.add(objectInputStream.readObject(), objectInputStream.readInt());
|
|
}
|
|
}
|
|
|
|
static <K, V> void a(Multimap<K, V> multimap, ObjectOutputStream objectOutputStream) throws IOException {
|
|
objectOutputStream.writeInt(multimap.asMap().size());
|
|
for (Map.Entry<K, Collection<V>> entry : multimap.asMap().entrySet()) {
|
|
objectOutputStream.writeObject(entry.getKey());
|
|
objectOutputStream.writeInt(entry.getValue().size());
|
|
Iterator<V> it = entry.getValue().iterator();
|
|
while (it.hasNext()) {
|
|
objectOutputStream.writeObject(it.next());
|
|
}
|
|
}
|
|
}
|
|
|
|
static <K, V> void a(Multimap<K, V> multimap, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
|
a(multimap, objectInputStream, objectInputStream.readInt());
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
static <K, V> void a(Multimap<K, V> multimap, ObjectInputStream objectInputStream, int i) throws IOException, ClassNotFoundException {
|
|
for (int i2 = 0; i2 < i; i2++) {
|
|
Collection collection = multimap.get(objectInputStream.readObject());
|
|
int readInt = objectInputStream.readInt();
|
|
for (int i3 = 0; i3 < readInt; i3++) {
|
|
collection.add(objectInputStream.readObject());
|
|
}
|
|
}
|
|
}
|
|
|
|
static <T> FieldSetter<T> a(Class<T> cls, String str) {
|
|
try {
|
|
return new FieldSetter<>(cls.getDeclaredField(str));
|
|
} catch (NoSuchFieldException e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
}
|