206 lines
9.5 KiB
Java
206 lines
9.5 KiB
Java
package com.thoughtworks.xstream.converters.collections;
|
|
|
|
import com.thoughtworks.xstream.converters.MarshallingContext;
|
|
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
|
import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
|
|
import com.thoughtworks.xstream.core.JVM;
|
|
import com.thoughtworks.xstream.core.util.Fields;
|
|
import com.thoughtworks.xstream.core.util.PresortedSet;
|
|
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
|
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
|
import com.thoughtworks.xstream.mapper.Mapper;
|
|
import java.lang.reflect.Field;
|
|
import java.util.AbstractList;
|
|
import java.util.Comparator;
|
|
import java.util.Map;
|
|
import java.util.SortedSet;
|
|
import java.util.TreeMap;
|
|
import java.util.TreeSet;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class TreeSetConverter extends CollectionConverter {
|
|
static /* synthetic */ Class class$java$lang$Object;
|
|
static /* synthetic */ Class class$java$util$SortedMap;
|
|
static /* synthetic */ Class class$java$util$TreeSet;
|
|
private static final Object constantValue;
|
|
private static final Field sortedMapField;
|
|
private transient TreeMapConverter treeMapConverter;
|
|
|
|
static {
|
|
Field field;
|
|
Map map;
|
|
Object obj = null;
|
|
if (JVM.hasOptimizedTreeSetAddAll()) {
|
|
Class cls = class$java$util$TreeSet;
|
|
if (cls == null) {
|
|
cls = class$("java.util.TreeSet");
|
|
class$java$util$TreeSet = cls;
|
|
}
|
|
Class cls2 = class$java$util$SortedMap;
|
|
if (cls2 == null) {
|
|
cls2 = class$("java.util.SortedMap");
|
|
class$java$util$SortedMap = cls2;
|
|
}
|
|
field = Fields.locate(cls, cls2, false);
|
|
} else {
|
|
field = null;
|
|
}
|
|
sortedMapField = field;
|
|
if (sortedMapField != null) {
|
|
TreeSet treeSet = new TreeSet();
|
|
treeSet.add("1");
|
|
treeSet.add("2");
|
|
try {
|
|
map = (Map) sortedMapField.get(treeSet);
|
|
} catch (IllegalAccessException unused) {
|
|
map = null;
|
|
}
|
|
if (map != null) {
|
|
Object[] array = map.values().toArray();
|
|
if (array[0] == array[1]) {
|
|
obj = array[0];
|
|
}
|
|
}
|
|
} else {
|
|
Class cls3 = class$java$util$TreeSet;
|
|
if (cls3 == null) {
|
|
cls3 = class$("java.util.TreeSet");
|
|
class$java$util$TreeSet = cls3;
|
|
}
|
|
Class cls4 = class$java$lang$Object;
|
|
if (cls4 == null) {
|
|
cls4 = class$("java.lang.Object");
|
|
class$java$lang$Object = cls4;
|
|
}
|
|
Field locate = Fields.locate(cls3, cls4, true);
|
|
if (locate != null) {
|
|
try {
|
|
obj = locate.get(null);
|
|
} catch (IllegalAccessException unused2) {
|
|
}
|
|
}
|
|
}
|
|
constantValue = obj;
|
|
}
|
|
|
|
/* JADX WARN: Illegal instructions before constructor call */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public TreeSetConverter(com.thoughtworks.xstream.mapper.Mapper r2) {
|
|
/*
|
|
r1 = this;
|
|
java.lang.Class r0 = com.thoughtworks.xstream.converters.collections.TreeSetConverter.class$java$util$TreeSet
|
|
if (r0 != 0) goto Lc
|
|
java.lang.String r0 = "java.util.TreeSet"
|
|
java.lang.Class r0 = class$(r0)
|
|
com.thoughtworks.xstream.converters.collections.TreeSetConverter.class$java$util$TreeSet = r0
|
|
Lc:
|
|
r1.<init>(r2, r0)
|
|
r1.readResolve()
|
|
return
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.thoughtworks.xstream.converters.collections.TreeSetConverter.<init>(com.thoughtworks.xstream.mapper.Mapper):void");
|
|
}
|
|
|
|
static /* synthetic */ Class class$(String str) {
|
|
try {
|
|
return Class.forName(str);
|
|
} catch (ClassNotFoundException e) {
|
|
throw new NoClassDefFoundError().initCause(e);
|
|
}
|
|
}
|
|
|
|
private Object readResolve() {
|
|
this.treeMapConverter = new TreeMapConverter(mapper()) { // from class: com.thoughtworks.xstream.converters.collections.TreeSetConverter.1
|
|
@Override // com.thoughtworks.xstream.converters.collections.MapConverter
|
|
protected void populateMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, final Map map2) {
|
|
TreeSetConverter.this.populateCollection(hierarchicalStreamReader, unmarshallingContext, new AbstractList() { // from class: com.thoughtworks.xstream.converters.collections.TreeSetConverter.1.1
|
|
@Override // java.util.AbstractList, java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public boolean add(Object obj) {
|
|
return map2.put(obj, TreeSetConverter.constantValue != null ? TreeSetConverter.constantValue : obj) != null;
|
|
}
|
|
|
|
@Override // java.util.AbstractList, java.util.List
|
|
public Object get(int i) {
|
|
return null;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.List
|
|
public int size() {
|
|
return map2.size();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.converters.collections.MapConverter
|
|
protected void putCurrentEntryIntoMap(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext, Map map, Map map2) {
|
|
Object readItem = readItem(hierarchicalStreamReader, unmarshallingContext, map);
|
|
map2.put(readItem, readItem);
|
|
}
|
|
};
|
|
return this;
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
|
|
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
|
this.treeMapConverter.marshalComparator(((SortedSet) obj).comparator(), hierarchicalStreamWriter, marshallingContext);
|
|
super.marshal(obj, hierarchicalStreamWriter, marshallingContext);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Type inference failed for: r4v10, types: [java.util.TreeSet] */
|
|
/* JADX WARN: Type inference failed for: r4v4, types: [java.util.Collection, java.util.TreeSet] */
|
|
/* JADX WARN: Type inference failed for: r4v5, types: [java.lang.Object, java.util.TreeSet] */
|
|
/* JADX WARN: Type inference failed for: r4v9, types: [java.util.TreeSet] */
|
|
/* JADX WARN: Type inference failed for: r5v0, types: [java.lang.reflect.Field] */
|
|
/* JADX WARN: Type inference failed for: r7v0, types: [com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.TreeSetConverter] */
|
|
@Override // com.thoughtworks.xstream.converters.collections.CollectionConverter, com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter, com.thoughtworks.xstream.converters.Converter
|
|
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
|
TreeMap treeMap;
|
|
TreeMap treeMap2;
|
|
TreeMap treeMap3;
|
|
TreeMap treeMap4 = null;
|
|
Comparator unmarshalComparator = this.treeMapConverter.unmarshalComparator(hierarchicalStreamReader, unmarshallingContext, null);
|
|
boolean z = unmarshalComparator instanceof Mapper.Null;
|
|
Comparator comparator = z ? null : unmarshalComparator;
|
|
if (sortedMapField != null) {
|
|
?? treeSet = comparator == null ? new TreeSet() : new TreeSet(comparator);
|
|
try {
|
|
Object obj = sortedMapField.get(treeSet);
|
|
if (obj instanceof TreeMap) {
|
|
treeMap3 = (TreeMap) obj;
|
|
treeMap4 = treeSet;
|
|
} else {
|
|
treeMap3 = null;
|
|
}
|
|
treeMap = treeMap4;
|
|
treeMap4 = treeMap3;
|
|
} catch (IllegalAccessException e) {
|
|
throw new ObjectAccessException("Cannot get backing map of TreeSet", e);
|
|
}
|
|
} else {
|
|
treeMap = null;
|
|
}
|
|
if (treeMap4 == null) {
|
|
PresortedSet presortedSet = new PresortedSet(comparator);
|
|
?? treeSet2 = comparator == null ? new TreeSet() : new TreeSet(comparator);
|
|
if (z) {
|
|
addCurrentElementToCollection(hierarchicalStreamReader, unmarshallingContext, treeSet2, presortedSet);
|
|
hierarchicalStreamReader.moveUp();
|
|
}
|
|
populateCollection(hierarchicalStreamReader, unmarshallingContext, treeSet2, presortedSet);
|
|
treeMap2 = treeSet2;
|
|
if (presortedSet.size() > 0) {
|
|
treeSet2.addAll(presortedSet);
|
|
treeMap2 = treeSet2;
|
|
}
|
|
} else {
|
|
this.treeMapConverter.populateTreeMap(hierarchicalStreamReader, unmarshallingContext, treeMap4, unmarshalComparator);
|
|
treeMap2 = treeMap;
|
|
}
|
|
return treeMap2;
|
|
}
|
|
}
|