Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
package com.google.gson;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/* loaded from: classes.dex */
final class DefaultDateTypeAdapter extends TypeAdapter<Date> {
private static final String SIMPLE_NAME = "DefaultDateTypeAdapter";
private final Class<? extends Date> dateType;
private final DateFormat enUsFormat;
private final DateFormat localFormat;
DefaultDateTypeAdapter(Class<? extends Date> cls) {
this(cls, DateFormat.getDateTimeInstance(2, 2, Locale.US), DateFormat.getDateTimeInstance(2, 2));
}
private Date deserializeToDate(String str) {
Date parse;
synchronized (this.localFormat) {
try {
try {
try {
parse = this.localFormat.parse(str);
} catch (ParseException unused) {
return this.enUsFormat.parse(str);
}
} catch (ParseException unused2) {
return ISO8601Utils.parse(str, new ParsePosition(0));
}
} catch (ParseException e) {
throw new JsonSyntaxException(str, e);
}
}
return parse;
}
public String toString() {
return SIMPLE_NAME + '(' + this.localFormat.getClass().getSimpleName() + ')';
}
@Override // com.google.gson.TypeAdapter
public Date read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
Date deserializeToDate = deserializeToDate(jsonReader.nextString());
Class<? extends Date> cls = this.dateType;
if (cls == Date.class) {
return deserializeToDate;
}
if (cls == Timestamp.class) {
return new Timestamp(deserializeToDate.getTime());
}
if (cls == java.sql.Date.class) {
return new java.sql.Date(deserializeToDate.getTime());
}
throw new AssertionError();
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Date date) throws IOException {
if (date == null) {
jsonWriter.nullValue();
return;
}
synchronized (this.localFormat) {
jsonWriter.value(this.enUsFormat.format(date));
}
}
DefaultDateTypeAdapter(Class<? extends Date> cls, String str) {
this(cls, new SimpleDateFormat(str, Locale.US), new SimpleDateFormat(str));
}
DefaultDateTypeAdapter(Class<? extends Date> cls, int i) {
this(cls, DateFormat.getDateInstance(i, Locale.US), DateFormat.getDateInstance(i));
}
public DefaultDateTypeAdapter(int i, int i2) {
this((Class<? extends Date>) Date.class, DateFormat.getDateTimeInstance(i, i2, Locale.US), DateFormat.getDateTimeInstance(i, i2));
}
public DefaultDateTypeAdapter(Class<? extends Date> cls, int i, int i2) {
this(cls, DateFormat.getDateTimeInstance(i, i2, Locale.US), DateFormat.getDateTimeInstance(i, i2));
}
DefaultDateTypeAdapter(Class<? extends Date> cls, DateFormat dateFormat, DateFormat dateFormat2) {
if (cls != Date.class && cls != java.sql.Date.class && cls != Timestamp.class) {
throw new IllegalArgumentException("Date type must be one of " + Date.class + ", " + Timestamp.class + ", or " + java.sql.Date.class + " but was " + cls);
}
this.dateType = cls;
this.enUsFormat = dateFormat;
this.localFormat = dateFormat2;
}
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
/* loaded from: classes.dex */
public interface ExclusionStrategy {
boolean shouldSkipClass(Class<?> cls);
boolean shouldSkipField(FieldAttributes fieldAttributes);
}

View File

@@ -0,0 +1,54 @@
package com.google.gson;
import com.google.gson.internal.C$Gson$Preconditions;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
/* loaded from: classes.dex */
public final class FieldAttributes {
private final Field field;
public FieldAttributes(Field field) {
C$Gson$Preconditions.checkNotNull(field);
this.field = field;
}
Object get(Object obj) throws IllegalAccessException {
return this.field.get(obj);
}
public <T extends Annotation> T getAnnotation(Class<T> cls) {
return (T) this.field.getAnnotation(cls);
}
public Collection<Annotation> getAnnotations() {
return Arrays.asList(this.field.getAnnotations());
}
public Class<?> getDeclaredClass() {
return this.field.getType();
}
public Type getDeclaredType() {
return this.field.getGenericType();
}
public Class<?> getDeclaringClass() {
return this.field.getDeclaringClass();
}
public String getName() {
return this.field.getName();
}
public boolean hasModifier(int i) {
return (i & this.field.getModifiers()) != 0;
}
boolean isSynthetic() {
return this.field.isSynthetic();
}
}

View File

@@ -0,0 +1,75 @@
package com.google.gson;
import java.lang.reflect.Field;
import java.util.Locale;
/* loaded from: classes.dex */
public enum FieldNamingPolicy implements FieldNamingStrategy {
IDENTITY { // from class: com.google.gson.FieldNamingPolicy.1
@Override // com.google.gson.FieldNamingStrategy
public String translateName(Field field) {
return field.getName();
}
},
UPPER_CAMEL_CASE { // from class: com.google.gson.FieldNamingPolicy.2
@Override // com.google.gson.FieldNamingStrategy
public String translateName(Field field) {
return FieldNamingPolicy.upperCaseFirstLetter(field.getName());
}
},
UPPER_CAMEL_CASE_WITH_SPACES { // from class: com.google.gson.FieldNamingPolicy.3
@Override // com.google.gson.FieldNamingStrategy
public String translateName(Field field) {
return FieldNamingPolicy.upperCaseFirstLetter(FieldNamingPolicy.separateCamelCase(field.getName(), " "));
}
},
LOWER_CASE_WITH_UNDERSCORES { // from class: com.google.gson.FieldNamingPolicy.4
@Override // com.google.gson.FieldNamingStrategy
public String translateName(Field field) {
return FieldNamingPolicy.separateCamelCase(field.getName(), "_").toLowerCase(Locale.ENGLISH);
}
},
LOWER_CASE_WITH_DASHES { // from class: com.google.gson.FieldNamingPolicy.5
@Override // com.google.gson.FieldNamingStrategy
public String translateName(Field field) {
return FieldNamingPolicy.separateCamelCase(field.getName(), "-").toLowerCase(Locale.ENGLISH);
}
};
private static String modifyString(char c, String str, int i) {
if (i >= str.length()) {
return String.valueOf(c);
}
return c + str.substring(i);
}
static String separateCamelCase(String str, String str2) {
StringBuilder sb = new StringBuilder();
int length = str.length();
for (int i = 0; i < length; i++) {
char charAt = str.charAt(i);
if (Character.isUpperCase(charAt) && sb.length() != 0) {
sb.append(str2);
}
sb.append(charAt);
}
return sb.toString();
}
static String upperCaseFirstLetter(String str) {
StringBuilder sb = new StringBuilder();
int i = 0;
char charAt = str.charAt(0);
int length = str.length();
while (i < length - 1 && !Character.isLetter(charAt)) {
sb.append(charAt);
i++;
charAt = str.charAt(i);
}
if (Character.isUpperCase(charAt)) {
return str;
}
sb.append(modifyString(Character.toUpperCase(charAt), str, i + 1));
return sb.toString();
}
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import java.lang.reflect.Field;
/* loaded from: classes.dex */
public interface FieldNamingStrategy {
String translateName(Field field);
}

View File

@@ -0,0 +1,549 @@
package com.google.gson;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.Excluder;
import com.google.gson.internal.Primitives;
import com.google.gson.internal.Streams;
import com.google.gson.internal.bind.ArrayTypeAdapter;
import com.google.gson.internal.bind.CollectionTypeAdapterFactory;
import com.google.gson.internal.bind.DateTypeAdapter;
import com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory;
import com.google.gson.internal.bind.JsonTreeReader;
import com.google.gson.internal.bind.JsonTreeWriter;
import com.google.gson.internal.bind.MapTypeAdapterFactory;
import com.google.gson.internal.bind.ObjectTypeAdapter;
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
import com.google.gson.internal.bind.SqlDateTypeAdapter;
import com.google.gson.internal.bind.TimeTypeAdapter;
import com.google.gson.internal.bind.TypeAdapters;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import com.google.gson.stream.MalformedJsonException;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;
/* loaded from: classes.dex */
public final class Gson {
static final boolean DEFAULT_COMPLEX_MAP_KEYS = false;
static final boolean DEFAULT_ESCAPE_HTML = true;
static final boolean DEFAULT_JSON_NON_EXECUTABLE = false;
static final boolean DEFAULT_LENIENT = false;
static final boolean DEFAULT_PRETTY_PRINT = false;
static final boolean DEFAULT_SERIALIZE_NULLS = false;
static final boolean DEFAULT_SPECIALIZE_FLOAT_VALUES = false;
private static final String JSON_NON_EXECUTABLE_PREFIX = ")]}'\n";
private static final TypeToken<?> NULL_KEY_SURROGATE = TypeToken.get(Object.class);
private final ThreadLocal<Map<TypeToken<?>, FutureTypeAdapter<?>>> calls;
private final ConstructorConstructor constructorConstructor;
private final Excluder excluder;
private final List<TypeAdapterFactory> factories;
private final FieldNamingStrategy fieldNamingStrategy;
private final boolean generateNonExecutableJson;
private final boolean htmlSafe;
private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;
private final boolean lenient;
private final boolean prettyPrinting;
private final boolean serializeNulls;
private final Map<TypeToken<?>, TypeAdapter<?>> typeTokenCache;
static class FutureTypeAdapter<T> extends TypeAdapter<T> {
private TypeAdapter<T> delegate;
FutureTypeAdapter() {
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
TypeAdapter<T> typeAdapter = this.delegate;
if (typeAdapter != null) {
return typeAdapter.read(jsonReader);
}
throw new IllegalStateException();
}
public void setDelegate(TypeAdapter<T> typeAdapter) {
if (this.delegate != null) {
throw new AssertionError();
}
this.delegate = typeAdapter;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
TypeAdapter<T> typeAdapter = this.delegate;
if (typeAdapter == null) {
throw new IllegalStateException();
}
typeAdapter.write(jsonWriter, t);
}
}
public Gson() {
this(Excluder.DEFAULT, FieldNamingPolicy.IDENTITY, Collections.emptyMap(), false, false, false, true, false, false, false, LongSerializationPolicy.DEFAULT, Collections.emptyList());
}
private static void assertFullConsumption(Object obj, JsonReader jsonReader) {
if (obj != null) {
try {
if (jsonReader.peek() == JsonToken.END_DOCUMENT) {
} else {
throw new JsonIOException("JSON document was not fully consumed.");
}
} catch (MalformedJsonException e) {
throw new JsonSyntaxException(e);
} catch (IOException e2) {
throw new JsonIOException(e2);
}
}
}
private static TypeAdapter<AtomicLong> atomicLongAdapter(final TypeAdapter<Number> typeAdapter) {
return new TypeAdapter<AtomicLong>() { // from class: com.google.gson.Gson.4
@Override // com.google.gson.TypeAdapter
public AtomicLong read(JsonReader jsonReader) throws IOException {
return new AtomicLong(((Number) TypeAdapter.this.read(jsonReader)).longValue());
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, AtomicLong atomicLong) throws IOException {
TypeAdapter.this.write(jsonWriter, Long.valueOf(atomicLong.get()));
}
}.nullSafe();
}
private static TypeAdapter<AtomicLongArray> atomicLongArrayAdapter(final TypeAdapter<Number> typeAdapter) {
return new TypeAdapter<AtomicLongArray>() { // from class: com.google.gson.Gson.5
@Override // com.google.gson.TypeAdapter
public AtomicLongArray read(JsonReader jsonReader) throws IOException {
ArrayList arrayList = new ArrayList();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
arrayList.add(Long.valueOf(((Number) TypeAdapter.this.read(jsonReader)).longValue()));
}
jsonReader.endArray();
int size = arrayList.size();
AtomicLongArray atomicLongArray = new AtomicLongArray(size);
for (int i = 0; i < size; i++) {
atomicLongArray.set(i, ((Long) arrayList.get(i)).longValue());
}
return atomicLongArray;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, AtomicLongArray atomicLongArray) throws IOException {
jsonWriter.beginArray();
int length = atomicLongArray.length();
for (int i = 0; i < length; i++) {
TypeAdapter.this.write(jsonWriter, Long.valueOf(atomicLongArray.get(i)));
}
jsonWriter.endArray();
}
}.nullSafe();
}
static void checkValidFloatingPoint(double d) {
if (Double.isNaN(d) || Double.isInfinite(d)) {
throw new IllegalArgumentException(d + " is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.");
}
}
private TypeAdapter<Number> doubleAdapter(boolean z) {
return z ? TypeAdapters.DOUBLE : new TypeAdapter<Number>() { // from class: com.google.gson.Gson.1
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Double.valueOf(jsonReader.nextDouble());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
if (number == null) {
jsonWriter.nullValue();
} else {
Gson.checkValidFloatingPoint(number.doubleValue());
jsonWriter.value(number);
}
}
};
}
private TypeAdapter<Number> floatAdapter(boolean z) {
return z ? TypeAdapters.FLOAT : new TypeAdapter<Number>() { // from class: com.google.gson.Gson.2
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Float.valueOf((float) jsonReader.nextDouble());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
if (number == null) {
jsonWriter.nullValue();
} else {
Gson.checkValidFloatingPoint(number.floatValue());
jsonWriter.value(number);
}
}
};
}
private static TypeAdapter<Number> longAdapter(LongSerializationPolicy longSerializationPolicy) {
return longSerializationPolicy == LongSerializationPolicy.DEFAULT ? TypeAdapters.LONG : new TypeAdapter<Number>() { // from class: com.google.gson.Gson.3
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Long.valueOf(jsonReader.nextLong());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
if (number == null) {
jsonWriter.nullValue();
} else {
jsonWriter.value(number.toString());
}
}
};
}
public Excluder excluder() {
return this.excluder;
}
public FieldNamingStrategy fieldNamingStrategy() {
return this.fieldNamingStrategy;
}
public <T> T fromJson(String str, Class<T> cls) throws JsonSyntaxException {
return (T) Primitives.wrap(cls).cast(fromJson(str, (Type) cls));
}
public <T> TypeAdapter<T> getAdapter(TypeToken<T> typeToken) {
TypeAdapter<T> typeAdapter = (TypeAdapter) this.typeTokenCache.get(typeToken == null ? NULL_KEY_SURROGATE : typeToken);
if (typeAdapter != null) {
return typeAdapter;
}
Map<TypeToken<?>, FutureTypeAdapter<?>> map = this.calls.get();
boolean z = false;
if (map == null) {
map = new HashMap<>();
this.calls.set(map);
z = true;
}
FutureTypeAdapter<?> futureTypeAdapter = map.get(typeToken);
if (futureTypeAdapter != null) {
return futureTypeAdapter;
}
try {
FutureTypeAdapter<?> futureTypeAdapter2 = new FutureTypeAdapter<>();
map.put(typeToken, futureTypeAdapter2);
Iterator<TypeAdapterFactory> it = this.factories.iterator();
while (it.hasNext()) {
TypeAdapter<T> create = it.next().create(this, typeToken);
if (create != null) {
futureTypeAdapter2.setDelegate(create);
this.typeTokenCache.put(typeToken, create);
return create;
}
}
throw new IllegalArgumentException("GSON cannot handle " + typeToken);
} finally {
map.remove(typeToken);
if (z) {
this.calls.remove();
}
}
}
public <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory typeAdapterFactory, TypeToken<T> typeToken) {
if (!this.factories.contains(typeAdapterFactory)) {
typeAdapterFactory = this.jsonAdapterFactory;
}
boolean z = false;
for (TypeAdapterFactory typeAdapterFactory2 : this.factories) {
if (z) {
TypeAdapter<T> create = typeAdapterFactory2.create(this, typeToken);
if (create != null) {
return create;
}
} else if (typeAdapterFactory2 == typeAdapterFactory) {
z = true;
}
}
throw new IllegalArgumentException("GSON cannot serialize " + typeToken);
}
public boolean htmlSafe() {
return this.htmlSafe;
}
public JsonReader newJsonReader(Reader reader) {
JsonReader jsonReader = new JsonReader(reader);
jsonReader.setLenient(this.lenient);
return jsonReader;
}
public JsonWriter newJsonWriter(Writer writer) throws IOException {
if (this.generateNonExecutableJson) {
writer.write(JSON_NON_EXECUTABLE_PREFIX);
}
JsonWriter jsonWriter = new JsonWriter(writer);
if (this.prettyPrinting) {
jsonWriter.setIndent(" ");
}
jsonWriter.setSerializeNulls(this.serializeNulls);
return jsonWriter;
}
public boolean serializeNulls() {
return this.serializeNulls;
}
public String toJson(Object obj) {
return obj == null ? toJson((JsonElement) JsonNull.INSTANCE) : toJson(obj, obj.getClass());
}
public JsonElement toJsonTree(Object obj) {
return obj == null ? JsonNull.INSTANCE : toJsonTree(obj, obj.getClass());
}
public String toString() {
return "{serializeNulls:" + this.serializeNulls + ",factories:" + this.factories + ",instanceCreators:" + this.constructorConstructor + "}";
}
public <T> T fromJson(String str, Type type) throws JsonSyntaxException {
if (str == null) {
return null;
}
return (T) fromJson(new StringReader(str), type);
}
public String toJson(Object obj, Type type) {
StringWriter stringWriter = new StringWriter();
toJson(obj, type, stringWriter);
return stringWriter.toString();
}
public JsonElement toJsonTree(Object obj, Type type) {
JsonTreeWriter jsonTreeWriter = new JsonTreeWriter();
toJson(obj, type, jsonTreeWriter);
return jsonTreeWriter.get();
}
Gson(Excluder excluder, FieldNamingStrategy fieldNamingStrategy, Map<Type, InstanceCreator<?>> map, boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, LongSerializationPolicy longSerializationPolicy, List<TypeAdapterFactory> list) {
this.calls = new ThreadLocal<>();
this.typeTokenCache = new ConcurrentHashMap();
this.constructorConstructor = new ConstructorConstructor(map);
this.excluder = excluder;
this.fieldNamingStrategy = fieldNamingStrategy;
this.serializeNulls = z;
this.generateNonExecutableJson = z3;
this.htmlSafe = z4;
this.prettyPrinting = z5;
this.lenient = z6;
ArrayList arrayList = new ArrayList();
arrayList.add(TypeAdapters.JSON_ELEMENT_FACTORY);
arrayList.add(ObjectTypeAdapter.FACTORY);
arrayList.add(excluder);
arrayList.addAll(list);
arrayList.add(TypeAdapters.STRING_FACTORY);
arrayList.add(TypeAdapters.INTEGER_FACTORY);
arrayList.add(TypeAdapters.BOOLEAN_FACTORY);
arrayList.add(TypeAdapters.BYTE_FACTORY);
arrayList.add(TypeAdapters.SHORT_FACTORY);
TypeAdapter<Number> longAdapter = longAdapter(longSerializationPolicy);
arrayList.add(TypeAdapters.newFactory(Long.TYPE, Long.class, longAdapter));
arrayList.add(TypeAdapters.newFactory(Double.TYPE, Double.class, doubleAdapter(z7)));
arrayList.add(TypeAdapters.newFactory(Float.TYPE, Float.class, floatAdapter(z7)));
arrayList.add(TypeAdapters.NUMBER_FACTORY);
arrayList.add(TypeAdapters.ATOMIC_INTEGER_FACTORY);
arrayList.add(TypeAdapters.ATOMIC_BOOLEAN_FACTORY);
arrayList.add(TypeAdapters.newFactory(AtomicLong.class, atomicLongAdapter(longAdapter)));
arrayList.add(TypeAdapters.newFactory(AtomicLongArray.class, atomicLongArrayAdapter(longAdapter)));
arrayList.add(TypeAdapters.ATOMIC_INTEGER_ARRAY_FACTORY);
arrayList.add(TypeAdapters.CHARACTER_FACTORY);
arrayList.add(TypeAdapters.STRING_BUILDER_FACTORY);
arrayList.add(TypeAdapters.STRING_BUFFER_FACTORY);
arrayList.add(TypeAdapters.newFactory(BigDecimal.class, TypeAdapters.BIG_DECIMAL));
arrayList.add(TypeAdapters.newFactory(BigInteger.class, TypeAdapters.BIG_INTEGER));
arrayList.add(TypeAdapters.URL_FACTORY);
arrayList.add(TypeAdapters.URI_FACTORY);
arrayList.add(TypeAdapters.UUID_FACTORY);
arrayList.add(TypeAdapters.CURRENCY_FACTORY);
arrayList.add(TypeAdapters.LOCALE_FACTORY);
arrayList.add(TypeAdapters.INET_ADDRESS_FACTORY);
arrayList.add(TypeAdapters.BIT_SET_FACTORY);
arrayList.add(DateTypeAdapter.FACTORY);
arrayList.add(TypeAdapters.CALENDAR_FACTORY);
arrayList.add(TimeTypeAdapter.FACTORY);
arrayList.add(SqlDateTypeAdapter.FACTORY);
arrayList.add(TypeAdapters.TIMESTAMP_FACTORY);
arrayList.add(ArrayTypeAdapter.FACTORY);
arrayList.add(TypeAdapters.CLASS_FACTORY);
arrayList.add(new CollectionTypeAdapterFactory(this.constructorConstructor));
arrayList.add(new MapTypeAdapterFactory(this.constructorConstructor, z2));
this.jsonAdapterFactory = new JsonAdapterAnnotationTypeAdapterFactory(this.constructorConstructor);
arrayList.add(this.jsonAdapterFactory);
arrayList.add(TypeAdapters.ENUM_FACTORY);
arrayList.add(new ReflectiveTypeAdapterFactory(this.constructorConstructor, fieldNamingStrategy, excluder, this.jsonAdapterFactory));
this.factories = Collections.unmodifiableList(arrayList);
}
public <T> T fromJson(Reader reader, Class<T> cls) throws JsonSyntaxException, JsonIOException {
JsonReader newJsonReader = newJsonReader(reader);
Object fromJson = fromJson(newJsonReader, cls);
assertFullConsumption(fromJson, newJsonReader);
return (T) Primitives.wrap(cls).cast(fromJson);
}
public void toJson(Object obj, Appendable appendable) throws JsonIOException {
if (obj != null) {
toJson(obj, obj.getClass(), appendable);
} else {
toJson((JsonElement) JsonNull.INSTANCE, appendable);
}
}
public void toJson(Object obj, Type type, Appendable appendable) throws JsonIOException {
try {
toJson(obj, type, newJsonWriter(Streams.writerForAppendable(appendable)));
} catch (IOException e) {
throw new JsonIOException(e);
}
}
public <T> T fromJson(Reader reader, Type type) throws JsonIOException, JsonSyntaxException {
JsonReader newJsonReader = newJsonReader(reader);
T t = (T) fromJson(newJsonReader, type);
assertFullConsumption(t, newJsonReader);
return t;
}
public void toJson(Object obj, Type type, JsonWriter jsonWriter) throws JsonIOException {
TypeAdapter adapter = getAdapter(TypeToken.get(type));
boolean isLenient = jsonWriter.isLenient();
jsonWriter.setLenient(true);
boolean isHtmlSafe = jsonWriter.isHtmlSafe();
jsonWriter.setHtmlSafe(this.htmlSafe);
boolean serializeNulls = jsonWriter.getSerializeNulls();
jsonWriter.setSerializeNulls(this.serializeNulls);
try {
try {
adapter.write(jsonWriter, obj);
} catch (IOException e) {
throw new JsonIOException(e);
}
} finally {
jsonWriter.setLenient(isLenient);
jsonWriter.setHtmlSafe(isHtmlSafe);
jsonWriter.setSerializeNulls(serializeNulls);
}
}
public <T> T fromJson(JsonReader jsonReader, Type type) throws JsonIOException, JsonSyntaxException {
boolean isLenient = jsonReader.isLenient();
boolean z = true;
jsonReader.setLenient(true);
try {
try {
try {
jsonReader.peek();
z = false;
T read = getAdapter(TypeToken.get(type)).read(jsonReader);
jsonReader.setLenient(isLenient);
return read;
} catch (EOFException e) {
if (z) {
jsonReader.setLenient(isLenient);
return null;
}
throw new JsonSyntaxException(e);
} catch (IllegalStateException e2) {
throw new JsonSyntaxException(e2);
}
} catch (IOException e3) {
throw new JsonSyntaxException(e3);
}
} catch (Throwable th) {
jsonReader.setLenient(isLenient);
throw th;
}
}
public <T> TypeAdapter<T> getAdapter(Class<T> cls) {
return getAdapter(TypeToken.get((Class) cls));
}
public <T> T fromJson(JsonElement jsonElement, Class<T> cls) throws JsonSyntaxException {
return (T) Primitives.wrap(cls).cast(fromJson(jsonElement, (Type) cls));
}
public <T> T fromJson(JsonElement jsonElement, Type type) throws JsonSyntaxException {
if (jsonElement == null) {
return null;
}
return (T) fromJson(new JsonTreeReader(jsonElement), type);
}
public String toJson(JsonElement jsonElement) {
StringWriter stringWriter = new StringWriter();
toJson(jsonElement, (Appendable) stringWriter);
return stringWriter.toString();
}
public void toJson(JsonElement jsonElement, Appendable appendable) throws JsonIOException {
try {
toJson(jsonElement, newJsonWriter(Streams.writerForAppendable(appendable)));
} catch (IOException e) {
throw new JsonIOException(e);
}
}
public void toJson(JsonElement jsonElement, JsonWriter jsonWriter) throws JsonIOException {
boolean isLenient = jsonWriter.isLenient();
jsonWriter.setLenient(true);
boolean isHtmlSafe = jsonWriter.isHtmlSafe();
jsonWriter.setHtmlSafe(this.htmlSafe);
boolean serializeNulls = jsonWriter.getSerializeNulls();
jsonWriter.setSerializeNulls(this.serializeNulls);
try {
try {
Streams.write(jsonElement, jsonWriter);
} catch (IOException e) {
throw new JsonIOException(e);
}
} finally {
jsonWriter.setLenient(isLenient);
jsonWriter.setHtmlSafe(isHtmlSafe);
jsonWriter.setSerializeNulls(serializeNulls);
}
}
}

View File

@@ -0,0 +1,207 @@
package com.google.gson;
import com.google.gson.internal.C$Gson$Preconditions;
import com.google.gson.internal.Excluder;
import com.google.gson.internal.bind.TreeTypeAdapter;
import com.google.gson.internal.bind.TypeAdapters;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public final class GsonBuilder {
private String datePattern;
private Excluder excluder = Excluder.DEFAULT;
private LongSerializationPolicy longSerializationPolicy = LongSerializationPolicy.DEFAULT;
private FieldNamingStrategy fieldNamingPolicy = FieldNamingPolicy.IDENTITY;
private final Map<Type, InstanceCreator<?>> instanceCreators = new HashMap();
private final List<TypeAdapterFactory> factories = new ArrayList();
private final List<TypeAdapterFactory> hierarchyFactories = new ArrayList();
private boolean serializeNulls = false;
private int dateStyle = 2;
private int timeStyle = 2;
private boolean complexMapKeySerialization = false;
private boolean serializeSpecialFloatingPointValues = false;
private boolean escapeHtmlChars = true;
private boolean prettyPrinting = false;
private boolean generateNonExecutableJson = false;
private boolean lenient = false;
private void addTypeAdaptersForDate(String str, int i, int i2, List<TypeAdapterFactory> list) {
DefaultDateTypeAdapter defaultDateTypeAdapter;
DefaultDateTypeAdapter defaultDateTypeAdapter2;
DefaultDateTypeAdapter defaultDateTypeAdapter3;
if (str != null && !"".equals(str.trim())) {
DefaultDateTypeAdapter defaultDateTypeAdapter4 = new DefaultDateTypeAdapter((Class<? extends Date>) Date.class, str);
defaultDateTypeAdapter2 = new DefaultDateTypeAdapter((Class<? extends Date>) Timestamp.class, str);
defaultDateTypeAdapter3 = new DefaultDateTypeAdapter((Class<? extends Date>) java.sql.Date.class, str);
defaultDateTypeAdapter = defaultDateTypeAdapter4;
} else {
if (i == 2 || i2 == 2) {
return;
}
defaultDateTypeAdapter = new DefaultDateTypeAdapter((Class<? extends Date>) Date.class, i, i2);
DefaultDateTypeAdapter defaultDateTypeAdapter5 = new DefaultDateTypeAdapter((Class<? extends Date>) Timestamp.class, i, i2);
DefaultDateTypeAdapter defaultDateTypeAdapter6 = new DefaultDateTypeAdapter((Class<? extends Date>) java.sql.Date.class, i, i2);
defaultDateTypeAdapter2 = defaultDateTypeAdapter5;
defaultDateTypeAdapter3 = defaultDateTypeAdapter6;
}
list.add(TypeAdapters.newFactory(Date.class, defaultDateTypeAdapter));
list.add(TypeAdapters.newFactory(Timestamp.class, defaultDateTypeAdapter2));
list.add(TypeAdapters.newFactory(java.sql.Date.class, defaultDateTypeAdapter3));
}
public GsonBuilder addDeserializationExclusionStrategy(ExclusionStrategy exclusionStrategy) {
this.excluder = this.excluder.withExclusionStrategy(exclusionStrategy, false, true);
return this;
}
public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy exclusionStrategy) {
this.excluder = this.excluder.withExclusionStrategy(exclusionStrategy, true, false);
return this;
}
public Gson create() {
List<TypeAdapterFactory> arrayList = new ArrayList<>(this.factories.size() + this.hierarchyFactories.size() + 3);
arrayList.addAll(this.factories);
Collections.reverse(arrayList);
ArrayList arrayList2 = new ArrayList(this.hierarchyFactories);
Collections.reverse(arrayList2);
arrayList.addAll(arrayList2);
addTypeAdaptersForDate(this.datePattern, this.dateStyle, this.timeStyle, arrayList);
return new Gson(this.excluder, this.fieldNamingPolicy, this.instanceCreators, this.serializeNulls, this.complexMapKeySerialization, this.generateNonExecutableJson, this.escapeHtmlChars, this.prettyPrinting, this.lenient, this.serializeSpecialFloatingPointValues, this.longSerializationPolicy, arrayList);
}
public GsonBuilder disableHtmlEscaping() {
this.escapeHtmlChars = false;
return this;
}
public GsonBuilder disableInnerClassSerialization() {
this.excluder = this.excluder.disableInnerClassSerialization();
return this;
}
public GsonBuilder enableComplexMapKeySerialization() {
this.complexMapKeySerialization = true;
return this;
}
public GsonBuilder excludeFieldsWithModifiers(int... iArr) {
this.excluder = this.excluder.withModifiers(iArr);
return this;
}
public GsonBuilder excludeFieldsWithoutExposeAnnotation() {
this.excluder = this.excluder.excludeFieldsWithoutExposeAnnotation();
return this;
}
public GsonBuilder generateNonExecutableJson() {
this.generateNonExecutableJson = true;
return this;
}
public GsonBuilder registerTypeAdapter(Type type, Object obj) {
boolean z = obj instanceof JsonSerializer;
C$Gson$Preconditions.checkArgument(z || (obj instanceof JsonDeserializer) || (obj instanceof InstanceCreator) || (obj instanceof TypeAdapter));
if (obj instanceof InstanceCreator) {
this.instanceCreators.put(type, (InstanceCreator) obj);
}
if (z || (obj instanceof JsonDeserializer)) {
this.factories.add(TreeTypeAdapter.newFactoryWithMatchRawType(TypeToken.get(type), obj));
}
if (obj instanceof TypeAdapter) {
this.factories.add(TypeAdapters.newFactory(TypeToken.get(type), (TypeAdapter) obj));
}
return this;
}
public GsonBuilder registerTypeAdapterFactory(TypeAdapterFactory typeAdapterFactory) {
this.factories.add(typeAdapterFactory);
return this;
}
public GsonBuilder registerTypeHierarchyAdapter(Class<?> cls, Object obj) {
boolean z = obj instanceof JsonSerializer;
C$Gson$Preconditions.checkArgument(z || (obj instanceof JsonDeserializer) || (obj instanceof TypeAdapter));
if ((obj instanceof JsonDeserializer) || z) {
this.hierarchyFactories.add(TreeTypeAdapter.newTypeHierarchyFactory(cls, obj));
}
if (obj instanceof TypeAdapter) {
this.factories.add(TypeAdapters.newTypeHierarchyFactory(cls, (TypeAdapter) obj));
}
return this;
}
public GsonBuilder serializeNulls() {
this.serializeNulls = true;
return this;
}
public GsonBuilder serializeSpecialFloatingPointValues() {
this.serializeSpecialFloatingPointValues = true;
return this;
}
public GsonBuilder setDateFormat(String str) {
this.datePattern = str;
return this;
}
public GsonBuilder setExclusionStrategies(ExclusionStrategy... exclusionStrategyArr) {
for (ExclusionStrategy exclusionStrategy : exclusionStrategyArr) {
this.excluder = this.excluder.withExclusionStrategy(exclusionStrategy, true, true);
}
return this;
}
public GsonBuilder setFieldNamingPolicy(FieldNamingPolicy fieldNamingPolicy) {
this.fieldNamingPolicy = fieldNamingPolicy;
return this;
}
public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {
this.fieldNamingPolicy = fieldNamingStrategy;
return this;
}
public GsonBuilder setLenient() {
this.lenient = true;
return this;
}
public GsonBuilder setLongSerializationPolicy(LongSerializationPolicy longSerializationPolicy) {
this.longSerializationPolicy = longSerializationPolicy;
return this;
}
public GsonBuilder setPrettyPrinting() {
this.prettyPrinting = true;
return this;
}
public GsonBuilder setVersion(double d) {
this.excluder = this.excluder.withVersion(d);
return this;
}
public GsonBuilder setDateFormat(int i) {
this.dateStyle = i;
this.datePattern = null;
return this;
}
public GsonBuilder setDateFormat(int i, int i2) {
this.dateStyle = i;
this.timeStyle = i2;
this.datePattern = null;
return this;
}
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public interface InstanceCreator<T> {
T createInstance(Type type);
}

View File

@@ -0,0 +1,193 @@
package com.google.gson;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class JsonArray extends JsonElement implements Iterable<JsonElement> {
private final List<JsonElement> elements;
public JsonArray() {
this.elements = new ArrayList();
}
public void add(Boolean bool) {
this.elements.add(bool == null ? JsonNull.INSTANCE : new JsonPrimitive(bool));
}
public void addAll(JsonArray jsonArray) {
this.elements.addAll(jsonArray.elements);
}
public boolean contains(JsonElement jsonElement) {
return this.elements.contains(jsonElement);
}
public boolean equals(Object obj) {
return obj == this || ((obj instanceof JsonArray) && ((JsonArray) obj).elements.equals(this.elements));
}
public JsonElement get(int i) {
return this.elements.get(i);
}
@Override // com.google.gson.JsonElement
public BigDecimal getAsBigDecimal() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBigDecimal();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public BigInteger getAsBigInteger() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBigInteger();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public boolean getAsBoolean() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsBoolean();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public byte getAsByte() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public char getAsCharacter() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsCharacter();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public double getAsDouble() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsDouble();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public float getAsFloat() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsFloat();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public int getAsInt() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsInt();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public long getAsLong() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsLong();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public Number getAsNumber() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsNumber();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public short getAsShort() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsShort();
}
throw new IllegalStateException();
}
@Override // com.google.gson.JsonElement
public String getAsString() {
if (this.elements.size() == 1) {
return this.elements.get(0).getAsString();
}
throw new IllegalStateException();
}
public int hashCode() {
return this.elements.hashCode();
}
@Override // java.lang.Iterable
public Iterator<JsonElement> iterator() {
return this.elements.iterator();
}
public boolean remove(JsonElement jsonElement) {
return this.elements.remove(jsonElement);
}
public JsonElement set(int i, JsonElement jsonElement) {
return this.elements.set(i, jsonElement);
}
public int size() {
return this.elements.size();
}
public void add(Character ch) {
this.elements.add(ch == null ? JsonNull.INSTANCE : new JsonPrimitive(ch));
}
@Override // com.google.gson.JsonElement
public JsonArray deepCopy() {
if (this.elements.isEmpty()) {
return new JsonArray();
}
JsonArray jsonArray = new JsonArray(this.elements.size());
Iterator<JsonElement> it = this.elements.iterator();
while (it.hasNext()) {
jsonArray.add(it.next().deepCopy());
}
return jsonArray;
}
public JsonElement remove(int i) {
return this.elements.remove(i);
}
public JsonArray(int i) {
this.elements = new ArrayList(i);
}
public void add(Number number) {
this.elements.add(number == null ? JsonNull.INSTANCE : new JsonPrimitive(number));
}
public void add(String str) {
this.elements.add(str == null ? JsonNull.INSTANCE : new JsonPrimitive(str));
}
public void add(JsonElement jsonElement) {
if (jsonElement == null) {
jsonElement = JsonNull.INSTANCE;
}
this.elements.add(jsonElement);
}
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public interface JsonDeserializationContext {
<T> T deserialize(JsonElement jsonElement, Type type) throws JsonParseException;
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public interface JsonDeserializer<T> {
T deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException;
}

View File

@@ -0,0 +1,121 @@
package com.google.gson;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
/* loaded from: classes.dex */
public abstract class JsonElement {
public abstract JsonElement deepCopy();
public BigDecimal getAsBigDecimal() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public BigInteger getAsBigInteger() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public boolean getAsBoolean() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
Boolean getAsBooleanWrapper() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public byte getAsByte() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public char getAsCharacter() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public double getAsDouble() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public float getAsFloat() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public int getAsInt() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public JsonArray getAsJsonArray() {
if (isJsonArray()) {
return (JsonArray) this;
}
throw new IllegalStateException("Not a JSON Array: " + this);
}
public JsonNull getAsJsonNull() {
if (isJsonNull()) {
return (JsonNull) this;
}
throw new IllegalStateException("Not a JSON Null: " + this);
}
public JsonObject getAsJsonObject() {
if (isJsonObject()) {
return (JsonObject) this;
}
throw new IllegalStateException("Not a JSON Object: " + this);
}
public JsonPrimitive getAsJsonPrimitive() {
if (isJsonPrimitive()) {
return (JsonPrimitive) this;
}
throw new IllegalStateException("Not a JSON Primitive: " + this);
}
public long getAsLong() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public Number getAsNumber() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public short getAsShort() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public String getAsString() {
throw new UnsupportedOperationException(getClass().getSimpleName());
}
public boolean isJsonArray() {
return this instanceof JsonArray;
}
public boolean isJsonNull() {
return this instanceof JsonNull;
}
public boolean isJsonObject() {
return this instanceof JsonObject;
}
public boolean isJsonPrimitive() {
return this instanceof JsonPrimitive;
}
public String toString() {
try {
StringWriter stringWriter = new StringWriter();
JsonWriter jsonWriter = new JsonWriter(stringWriter);
jsonWriter.setLenient(true);
Streams.write(this, jsonWriter);
return stringWriter.toString();
} catch (IOException e) {
throw new AssertionError(e);
}
}
}

View File

@@ -0,0 +1,18 @@
package com.google.gson;
/* loaded from: classes.dex */
public final class JsonIOException extends JsonParseException {
private static final long serialVersionUID = 1;
public JsonIOException(String str) {
super(str);
}
public JsonIOException(String str, Throwable th) {
super(str, th);
}
public JsonIOException(Throwable th) {
super(th);
}
}

View File

@@ -0,0 +1,23 @@
package com.google.gson;
/* loaded from: classes.dex */
public final class JsonNull extends JsonElement {
public static final JsonNull INSTANCE = new JsonNull();
@Deprecated
public JsonNull() {
}
public boolean equals(Object obj) {
return this == obj || (obj instanceof JsonNull);
}
public int hashCode() {
return JsonNull.class.hashCode();
}
@Override // com.google.gson.JsonElement
public JsonNull deepCopy() {
return INSTANCE;
}
}

View File

@@ -0,0 +1,90 @@
package com.google.gson;
import com.google.gson.internal.LinkedTreeMap;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public final class JsonObject extends JsonElement {
private final LinkedTreeMap<String, JsonElement> members = new LinkedTreeMap<>();
private JsonElement createJsonElement(Object obj) {
return obj == null ? JsonNull.INSTANCE : new JsonPrimitive(obj);
}
public void add(String str, JsonElement jsonElement) {
if (jsonElement == null) {
jsonElement = JsonNull.INSTANCE;
}
this.members.put(str, jsonElement);
}
public void addProperty(String str, String str2) {
add(str, createJsonElement(str2));
}
public Set<Map.Entry<String, JsonElement>> entrySet() {
return this.members.entrySet();
}
public boolean equals(Object obj) {
return obj == this || ((obj instanceof JsonObject) && ((JsonObject) obj).members.equals(this.members));
}
public JsonElement get(String str) {
return this.members.get(str);
}
public JsonArray getAsJsonArray(String str) {
return (JsonArray) this.members.get(str);
}
public JsonObject getAsJsonObject(String str) {
return (JsonObject) this.members.get(str);
}
public JsonPrimitive getAsJsonPrimitive(String str) {
return (JsonPrimitive) this.members.get(str);
}
public boolean has(String str) {
return this.members.containsKey(str);
}
public int hashCode() {
return this.members.hashCode();
}
public Set<String> keySet() {
return this.members.keySet();
}
public JsonElement remove(String str) {
return this.members.remove(str);
}
public int size() {
return this.members.size();
}
public void addProperty(String str, Number number) {
add(str, createJsonElement(number));
}
@Override // com.google.gson.JsonElement
public JsonObject deepCopy() {
JsonObject jsonObject = new JsonObject();
for (Map.Entry<String, JsonElement> entry : this.members.entrySet()) {
jsonObject.add(entry.getKey(), entry.getValue().deepCopy());
}
return jsonObject;
}
public void addProperty(String str, Boolean bool) {
add(str, createJsonElement(bool));
}
public void addProperty(String str, Character ch) {
add(str, createJsonElement(ch));
}
}

View File

@@ -0,0 +1,18 @@
package com.google.gson;
/* loaded from: classes.dex */
public class JsonParseException extends RuntimeException {
static final long serialVersionUID = -4086729973971783390L;
public JsonParseException(String str) {
super(str);
}
public JsonParseException(String str, Throwable th) {
super(str, th);
}
public JsonParseException(Throwable th) {
super(th);
}
}

View File

@@ -0,0 +1,49 @@
package com.google.gson;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
/* loaded from: classes.dex */
public final class JsonParser {
public JsonElement parse(String str) throws JsonSyntaxException {
return parse(new StringReader(str));
}
public JsonElement parse(Reader reader) throws JsonIOException, JsonSyntaxException {
try {
JsonReader jsonReader = new JsonReader(reader);
JsonElement parse = parse(jsonReader);
if (!parse.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
throw new JsonSyntaxException("Did not consume the entire document.");
}
return parse;
} catch (MalformedJsonException e) {
throw new JsonSyntaxException(e);
} catch (IOException e2) {
throw new JsonIOException(e2);
} catch (NumberFormatException e3) {
throw new JsonSyntaxException(e3);
}
}
public JsonElement parse(JsonReader jsonReader) throws JsonIOException, JsonSyntaxException {
boolean isLenient = jsonReader.isLenient();
jsonReader.setLenient(true);
try {
try {
return Streams.parse(jsonReader);
} catch (OutOfMemoryError e) {
throw new JsonParseException("Failed parsing JSON source: " + jsonReader + " to Json", e);
} catch (StackOverflowError e2) {
throw new JsonParseException("Failed parsing JSON source: " + jsonReader + " to Json", e2);
}
} finally {
jsonReader.setLenient(isLenient);
}
}
}

View File

@@ -0,0 +1,190 @@
package com.google.gson;
import com.google.gson.internal.C$Gson$Preconditions;
import com.google.gson.internal.LazilyParsedNumber;
import java.math.BigDecimal;
import java.math.BigInteger;
/* loaded from: classes.dex */
public final class JsonPrimitive extends JsonElement {
private static final Class<?>[] PRIMITIVE_TYPES = {Integer.TYPE, Long.TYPE, Short.TYPE, Float.TYPE, Double.TYPE, Byte.TYPE, Boolean.TYPE, Character.TYPE, Integer.class, Long.class, Short.class, Float.class, Double.class, Byte.class, Boolean.class, Character.class};
private Object value;
public JsonPrimitive(Boolean bool) {
setValue(bool);
}
private static boolean isIntegral(JsonPrimitive jsonPrimitive) {
Object obj = jsonPrimitive.value;
if (!(obj instanceof Number)) {
return false;
}
Number number = (Number) obj;
return (number instanceof BigInteger) || (number instanceof Long) || (number instanceof Integer) || (number instanceof Short) || (number instanceof Byte);
}
private static boolean isPrimitiveOrString(Object obj) {
if (obj instanceof String) {
return true;
}
Class<?> cls = obj.getClass();
for (Class<?> cls2 : PRIMITIVE_TYPES) {
if (cls2.isAssignableFrom(cls)) {
return true;
}
}
return false;
}
@Override // com.google.gson.JsonElement
public JsonPrimitive deepCopy() {
return this;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || JsonPrimitive.class != obj.getClass()) {
return false;
}
JsonPrimitive jsonPrimitive = (JsonPrimitive) obj;
if (this.value == null) {
return jsonPrimitive.value == null;
}
if (isIntegral(this) && isIntegral(jsonPrimitive)) {
return getAsNumber().longValue() == jsonPrimitive.getAsNumber().longValue();
}
if (!(this.value instanceof Number) || !(jsonPrimitive.value instanceof Number)) {
return this.value.equals(jsonPrimitive.value);
}
double doubleValue = getAsNumber().doubleValue();
double doubleValue2 = jsonPrimitive.getAsNumber().doubleValue();
if (doubleValue != doubleValue2) {
return Double.isNaN(doubleValue) && Double.isNaN(doubleValue2);
}
return true;
}
@Override // com.google.gson.JsonElement
public BigDecimal getAsBigDecimal() {
Object obj = this.value;
return obj instanceof BigDecimal ? (BigDecimal) obj : new BigDecimal(obj.toString());
}
@Override // com.google.gson.JsonElement
public BigInteger getAsBigInteger() {
Object obj = this.value;
return obj instanceof BigInteger ? (BigInteger) obj : new BigInteger(obj.toString());
}
@Override // com.google.gson.JsonElement
public boolean getAsBoolean() {
return isBoolean() ? getAsBooleanWrapper().booleanValue() : Boolean.parseBoolean(getAsString());
}
@Override // com.google.gson.JsonElement
Boolean getAsBooleanWrapper() {
return (Boolean) this.value;
}
@Override // com.google.gson.JsonElement
public byte getAsByte() {
return isNumber() ? getAsNumber().byteValue() : Byte.parseByte(getAsString());
}
@Override // com.google.gson.JsonElement
public char getAsCharacter() {
return getAsString().charAt(0);
}
@Override // com.google.gson.JsonElement
public double getAsDouble() {
return isNumber() ? getAsNumber().doubleValue() : Double.parseDouble(getAsString());
}
@Override // com.google.gson.JsonElement
public float getAsFloat() {
return isNumber() ? getAsNumber().floatValue() : Float.parseFloat(getAsString());
}
@Override // com.google.gson.JsonElement
public int getAsInt() {
return isNumber() ? getAsNumber().intValue() : Integer.parseInt(getAsString());
}
@Override // com.google.gson.JsonElement
public long getAsLong() {
return isNumber() ? getAsNumber().longValue() : Long.parseLong(getAsString());
}
@Override // com.google.gson.JsonElement
public Number getAsNumber() {
Object obj = this.value;
return obj instanceof String ? new LazilyParsedNumber((String) obj) : (Number) obj;
}
@Override // com.google.gson.JsonElement
public short getAsShort() {
return isNumber() ? getAsNumber().shortValue() : Short.parseShort(getAsString());
}
@Override // com.google.gson.JsonElement
public String getAsString() {
return isNumber() ? getAsNumber().toString() : isBoolean() ? getAsBooleanWrapper().toString() : (String) this.value;
}
public int hashCode() {
long doubleToLongBits;
if (this.value == null) {
return 31;
}
if (isIntegral(this)) {
doubleToLongBits = getAsNumber().longValue();
} else {
Object obj = this.value;
if (!(obj instanceof Number)) {
return obj.hashCode();
}
doubleToLongBits = Double.doubleToLongBits(getAsNumber().doubleValue());
}
return (int) ((doubleToLongBits >>> 32) ^ doubleToLongBits);
}
public boolean isBoolean() {
return this.value instanceof Boolean;
}
public boolean isNumber() {
return this.value instanceof Number;
}
public boolean isString() {
return this.value instanceof String;
}
void setValue(Object obj) {
if (obj instanceof Character) {
this.value = String.valueOf(((Character) obj).charValue());
} else {
C$Gson$Preconditions.checkArgument((obj instanceof Number) || isPrimitiveOrString(obj));
this.value = obj;
}
}
public JsonPrimitive(Number number) {
setValue(number);
}
public JsonPrimitive(String str) {
setValue(str);
}
public JsonPrimitive(Character ch) {
setValue(ch);
}
JsonPrimitive(Object obj) {
setValue(obj);
}
}

View File

@@ -0,0 +1,10 @@
package com.google.gson;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public interface JsonSerializationContext {
JsonElement serialize(Object obj);
JsonElement serialize(Object obj, Type type);
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public interface JsonSerializer<T> {
JsonElement serialize(T t, Type type, JsonSerializationContext jsonSerializationContext);
}

View File

@@ -0,0 +1,74 @@
package com.google.gson;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.MalformedJsonException;
import java.io.EOFException;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Iterator;
import java.util.NoSuchElementException;
/* loaded from: classes.dex */
public final class JsonStreamParser implements Iterator<JsonElement> {
private final Object lock;
private final JsonReader parser;
public JsonStreamParser(String str) {
this(new StringReader(str));
}
@Override // java.util.Iterator
public boolean hasNext() {
boolean z;
synchronized (this.lock) {
try {
try {
try {
z = this.parser.peek() != JsonToken.END_DOCUMENT;
} catch (MalformedJsonException e) {
throw new JsonSyntaxException(e);
}
} catch (IOException e2) {
throw new JsonIOException(e2);
}
} catch (Throwable th) {
throw th;
}
}
return z;
}
@Override // java.util.Iterator
public void remove() {
throw new UnsupportedOperationException();
}
public JsonStreamParser(Reader reader) {
this.parser = new JsonReader(reader);
this.parser.setLenient(true);
this.lock = new Object();
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // java.util.Iterator
public JsonElement next() throws JsonParseException {
if (!hasNext()) {
throw new NoSuchElementException();
}
try {
return Streams.parse(this.parser);
} catch (JsonParseException e) {
if (e.getCause() instanceof EOFException) {
throw new NoSuchElementException();
}
throw e;
} catch (OutOfMemoryError e2) {
throw new JsonParseException("Failed parsing JSON source to Json", e2);
} catch (StackOverflowError e3) {
throw new JsonParseException("Failed parsing JSON source to Json", e3);
}
}
}

View File

@@ -0,0 +1,18 @@
package com.google.gson;
/* loaded from: classes.dex */
public final class JsonSyntaxException extends JsonParseException {
private static final long serialVersionUID = 1;
public JsonSyntaxException(String str) {
super(str);
}
public JsonSyntaxException(String str, Throwable th) {
super(str, th);
}
public JsonSyntaxException(Throwable th) {
super(th);
}
}

View File

@@ -0,0 +1,19 @@
package com.google.gson;
/* loaded from: classes.dex */
public enum LongSerializationPolicy {
DEFAULT { // from class: com.google.gson.LongSerializationPolicy.1
@Override // com.google.gson.LongSerializationPolicy
public JsonElement serialize(Long l) {
return new JsonPrimitive((Number) l);
}
},
STRING { // from class: com.google.gson.LongSerializationPolicy.2
@Override // com.google.gson.LongSerializationPolicy
public JsonElement serialize(Long l) {
return new JsonPrimitive(String.valueOf(l));
}
};
public abstract JsonElement serialize(Long l);
}

View File

@@ -0,0 +1,81 @@
package com.google.gson;
import com.google.gson.internal.bind.JsonTreeReader;
import com.google.gson.internal.bind.JsonTreeWriter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
/* loaded from: classes.dex */
public abstract class TypeAdapter<T> {
public final T fromJson(Reader reader) throws IOException {
return read(new JsonReader(reader));
}
public final T fromJsonTree(JsonElement jsonElement) {
try {
return read(new JsonTreeReader(jsonElement));
} catch (IOException e) {
throw new JsonIOException(e);
}
}
public final TypeAdapter<T> nullSafe() {
return new TypeAdapter<T>() { // from class: com.google.gson.TypeAdapter.1
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return (T) TypeAdapter.this.read(jsonReader);
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
if (t == null) {
jsonWriter.nullValue();
} else {
TypeAdapter.this.write(jsonWriter, t);
}
}
};
}
public abstract T read(JsonReader jsonReader) throws IOException;
public final void toJson(Writer writer, T t) throws IOException {
write(new JsonWriter(writer), t);
}
public final JsonElement toJsonTree(T t) {
try {
JsonTreeWriter jsonTreeWriter = new JsonTreeWriter();
write(jsonTreeWriter, t);
return jsonTreeWriter.get();
} catch (IOException e) {
throw new JsonIOException(e);
}
}
public abstract void write(JsonWriter jsonWriter, T t) throws IOException;
public final T fromJson(String str) throws IOException {
return fromJson(new StringReader(str));
}
public final String toJson(T t) {
StringWriter stringWriter = new StringWriter();
try {
toJson(stringWriter, t);
return stringWriter.toString();
} catch (IOException e) {
throw new AssertionError(e);
}
}
}

View File

@@ -0,0 +1,8 @@
package com.google.gson;
import com.google.gson.reflect.TypeToken;
/* loaded from: classes.dex */
public interface TypeAdapterFactory {
<T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken);
}

View File

@@ -0,0 +1,17 @@
package com.google.gson.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface Expose {
boolean deserialize() default true;
boolean serialize() default true;
}

View File

@@ -0,0 +1,15 @@
package com.google.gson.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface JsonAdapter {
boolean nullSafe() default true;
Class<?> value();
}

View File

@@ -0,0 +1,17 @@
package com.google.gson.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD})
@Documented
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface SerializedName {
String[] alternate() default {};
String value();
}

View File

@@ -0,0 +1,15 @@
package com.google.gson.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.TYPE})
@Documented
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface Since {
double value();
}

View File

@@ -0,0 +1,15 @@
package com.google.gson.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.TYPE})
@Documented
@Retention(RetentionPolicy.RUNTIME)
/* loaded from: classes.dex */
public @interface Until {
double value();
}

View File

@@ -0,0 +1,22 @@
package com.google.gson.internal;
/* renamed from: com.google.gson.internal.$Gson$Preconditions, reason: invalid class name */
/* loaded from: classes.dex */
public final class C$Gson$Preconditions {
private C$Gson$Preconditions() {
throw new UnsupportedOperationException();
}
public static void checkArgument(boolean z) {
if (!z) {
throw new IllegalArgumentException();
}
}
public static <T> T checkNotNull(T t) {
if (t != null) {
return t;
}
throw new NullPointerException();
}
}

View File

@@ -0,0 +1,453 @@
package com.google.gson.internal;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
/* renamed from: com.google.gson.internal.$Gson$Types, reason: invalid class name */
/* loaded from: classes.dex */
public final class C$Gson$Types {
static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
/* compiled from: $Gson$Types.java */
/* renamed from: com.google.gson.internal.$Gson$Types$GenericArrayTypeImpl */
private static final class GenericArrayTypeImpl implements GenericArrayType, Serializable {
private static final long serialVersionUID = 0;
private final Type componentType;
public GenericArrayTypeImpl(Type type) {
this.componentType = C$Gson$Types.canonicalize(type);
}
public boolean equals(Object obj) {
return (obj instanceof GenericArrayType) && C$Gson$Types.equals(this, (GenericArrayType) obj);
}
@Override // java.lang.reflect.GenericArrayType
public Type getGenericComponentType() {
return this.componentType;
}
public int hashCode() {
return this.componentType.hashCode();
}
public String toString() {
return C$Gson$Types.typeToString(this.componentType) + "[]";
}
}
/* compiled from: $Gson$Types.java */
/* renamed from: com.google.gson.internal.$Gson$Types$ParameterizedTypeImpl */
private static final class ParameterizedTypeImpl implements ParameterizedType, Serializable {
private static final long serialVersionUID = 0;
private final Type ownerType;
private final Type rawType;
private final Type[] typeArguments;
public ParameterizedTypeImpl(Type type, Type type2, Type... typeArr) {
if (type2 instanceof Class) {
Class cls = (Class) type2;
boolean z = true;
boolean z2 = Modifier.isStatic(cls.getModifiers()) || cls.getEnclosingClass() == null;
if (type == null && !z2) {
z = false;
}
C$Gson$Preconditions.checkArgument(z);
}
this.ownerType = type == null ? null : C$Gson$Types.canonicalize(type);
this.rawType = C$Gson$Types.canonicalize(type2);
this.typeArguments = (Type[]) typeArr.clone();
int length = this.typeArguments.length;
for (int i = 0; i < length; i++) {
C$Gson$Preconditions.checkNotNull(this.typeArguments[i]);
C$Gson$Types.checkNotPrimitive(this.typeArguments[i]);
Type[] typeArr2 = this.typeArguments;
typeArr2[i] = C$Gson$Types.canonicalize(typeArr2[i]);
}
}
public boolean equals(Object obj) {
return (obj instanceof ParameterizedType) && C$Gson$Types.equals(this, (ParameterizedType) obj);
}
@Override // java.lang.reflect.ParameterizedType
public Type[] getActualTypeArguments() {
return (Type[]) this.typeArguments.clone();
}
@Override // java.lang.reflect.ParameterizedType
public Type getOwnerType() {
return this.ownerType;
}
@Override // java.lang.reflect.ParameterizedType
public Type getRawType() {
return this.rawType;
}
public int hashCode() {
return (Arrays.hashCode(this.typeArguments) ^ this.rawType.hashCode()) ^ C$Gson$Types.hashCodeOrZero(this.ownerType);
}
public String toString() {
int length = this.typeArguments.length;
if (length == 0) {
return C$Gson$Types.typeToString(this.rawType);
}
StringBuilder sb = new StringBuilder((length + 1) * 30);
sb.append(C$Gson$Types.typeToString(this.rawType));
sb.append("<");
sb.append(C$Gson$Types.typeToString(this.typeArguments[0]));
for (int i = 1; i < length; i++) {
sb.append(", ");
sb.append(C$Gson$Types.typeToString(this.typeArguments[i]));
}
sb.append(">");
return sb.toString();
}
}
/* compiled from: $Gson$Types.java */
/* renamed from: com.google.gson.internal.$Gson$Types$WildcardTypeImpl */
private static final class WildcardTypeImpl implements WildcardType, Serializable {
private static final long serialVersionUID = 0;
private final Type lowerBound;
private final Type upperBound;
public WildcardTypeImpl(Type[] typeArr, Type[] typeArr2) {
C$Gson$Preconditions.checkArgument(typeArr2.length <= 1);
C$Gson$Preconditions.checkArgument(typeArr.length == 1);
if (typeArr2.length != 1) {
C$Gson$Preconditions.checkNotNull(typeArr[0]);
C$Gson$Types.checkNotPrimitive(typeArr[0]);
this.lowerBound = null;
this.upperBound = C$Gson$Types.canonicalize(typeArr[0]);
return;
}
C$Gson$Preconditions.checkNotNull(typeArr2[0]);
C$Gson$Types.checkNotPrimitive(typeArr2[0]);
C$Gson$Preconditions.checkArgument(typeArr[0] == Object.class);
this.lowerBound = C$Gson$Types.canonicalize(typeArr2[0]);
this.upperBound = Object.class;
}
public boolean equals(Object obj) {
return (obj instanceof WildcardType) && C$Gson$Types.equals(this, (WildcardType) obj);
}
@Override // java.lang.reflect.WildcardType
public Type[] getLowerBounds() {
Type type = this.lowerBound;
return type != null ? new Type[]{type} : C$Gson$Types.EMPTY_TYPE_ARRAY;
}
@Override // java.lang.reflect.WildcardType
public Type[] getUpperBounds() {
return new Type[]{this.upperBound};
}
public int hashCode() {
Type type = this.lowerBound;
return (type != null ? type.hashCode() + 31 : 1) ^ (this.upperBound.hashCode() + 31);
}
public String toString() {
if (this.lowerBound != null) {
return "? super " + C$Gson$Types.typeToString(this.lowerBound);
}
if (this.upperBound == Object.class) {
return "?";
}
return "? extends " + C$Gson$Types.typeToString(this.upperBound);
}
}
private C$Gson$Types() {
throw new UnsupportedOperationException();
}
public static GenericArrayType arrayOf(Type type) {
return new GenericArrayTypeImpl(type);
}
public static Type canonicalize(Type type) {
if (type instanceof Class) {
Class cls = (Class) type;
return cls.isArray() ? new GenericArrayTypeImpl(canonicalize(cls.getComponentType())) : cls;
}
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
return new ParameterizedTypeImpl(parameterizedType.getOwnerType(), parameterizedType.getRawType(), parameterizedType.getActualTypeArguments());
}
if (type instanceof GenericArrayType) {
return new GenericArrayTypeImpl(((GenericArrayType) type).getGenericComponentType());
}
if (!(type instanceof WildcardType)) {
return type;
}
WildcardType wildcardType = (WildcardType) type;
return new WildcardTypeImpl(wildcardType.getUpperBounds(), wildcardType.getLowerBounds());
}
static void checkNotPrimitive(Type type) {
C$Gson$Preconditions.checkArgument(((type instanceof Class) && ((Class) type).isPrimitive()) ? false : true);
}
private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
Object genericDeclaration = typeVariable.getGenericDeclaration();
if (genericDeclaration instanceof Class) {
return (Class) genericDeclaration;
}
return null;
}
static boolean equal(Object obj, Object obj2) {
return obj == obj2 || (obj != null && obj.equals(obj2));
}
public static boolean equals(Type type, Type type2) {
if (type == type2) {
return true;
}
if (type instanceof Class) {
return type.equals(type2);
}
if (type instanceof ParameterizedType) {
if (!(type2 instanceof ParameterizedType)) {
return false;
}
ParameterizedType parameterizedType = (ParameterizedType) type;
ParameterizedType parameterizedType2 = (ParameterizedType) type2;
return equal(parameterizedType.getOwnerType(), parameterizedType2.getOwnerType()) && parameterizedType.getRawType().equals(parameterizedType2.getRawType()) && Arrays.equals(parameterizedType.getActualTypeArguments(), parameterizedType2.getActualTypeArguments());
}
if (type instanceof GenericArrayType) {
if (type2 instanceof GenericArrayType) {
return equals(((GenericArrayType) type).getGenericComponentType(), ((GenericArrayType) type2).getGenericComponentType());
}
return false;
}
if (type instanceof WildcardType) {
if (!(type2 instanceof WildcardType)) {
return false;
}
WildcardType wildcardType = (WildcardType) type;
WildcardType wildcardType2 = (WildcardType) type2;
return Arrays.equals(wildcardType.getUpperBounds(), wildcardType2.getUpperBounds()) && Arrays.equals(wildcardType.getLowerBounds(), wildcardType2.getLowerBounds());
}
if (!(type instanceof TypeVariable) || !(type2 instanceof TypeVariable)) {
return false;
}
TypeVariable typeVariable = (TypeVariable) type;
TypeVariable typeVariable2 = (TypeVariable) type2;
return typeVariable.getGenericDeclaration() == typeVariable2.getGenericDeclaration() && typeVariable.getName().equals(typeVariable2.getName());
}
public static Type getArrayComponentType(Type type) {
return type instanceof GenericArrayType ? ((GenericArrayType) type).getGenericComponentType() : ((Class) type).getComponentType();
}
public static Type getCollectionElementType(Type type, Class<?> cls) {
Type supertype = getSupertype(type, cls, Collection.class);
if (supertype instanceof WildcardType) {
supertype = ((WildcardType) supertype).getUpperBounds()[0];
}
return supertype instanceof ParameterizedType ? ((ParameterizedType) supertype).getActualTypeArguments()[0] : Object.class;
}
static Type getGenericSupertype(Type type, Class<?> cls, Class<?> cls2) {
if (cls2 == cls) {
return type;
}
if (cls2.isInterface()) {
Class<?>[] interfaces = cls.getInterfaces();
int length = interfaces.length;
for (int i = 0; i < length; i++) {
if (interfaces[i] == cls2) {
return cls.getGenericInterfaces()[i];
}
if (cls2.isAssignableFrom(interfaces[i])) {
return getGenericSupertype(cls.getGenericInterfaces()[i], interfaces[i], cls2);
}
}
}
if (!cls.isInterface()) {
while (cls != Object.class) {
Class<? super Object> superclass = cls.getSuperclass();
if (superclass == cls2) {
return cls.getGenericSuperclass();
}
if (cls2.isAssignableFrom(superclass)) {
return getGenericSupertype(cls.getGenericSuperclass(), superclass, cls2);
}
cls = superclass;
}
}
return cls2;
}
public static Type[] getMapKeyAndValueTypes(Type type, Class<?> cls) {
if (type == Properties.class) {
return new Type[]{String.class, String.class};
}
Type supertype = getSupertype(type, cls, Map.class);
return supertype instanceof ParameterizedType ? ((ParameterizedType) supertype).getActualTypeArguments() : new Type[]{Object.class, Object.class};
}
public static Class<?> getRawType(Type type) {
if (type instanceof Class) {
return (Class) type;
}
if (type instanceof ParameterizedType) {
Type rawType = ((ParameterizedType) type).getRawType();
C$Gson$Preconditions.checkArgument(rawType instanceof Class);
return (Class) rawType;
}
if (type instanceof GenericArrayType) {
return Array.newInstance(getRawType(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
}
if (type instanceof TypeVariable) {
return Object.class;
}
if (type instanceof WildcardType) {
return getRawType(((WildcardType) type).getUpperBounds()[0]);
}
throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + (type == null ? "null" : type.getClass().getName()));
}
static Type getSupertype(Type type, Class<?> cls, Class<?> cls2) {
C$Gson$Preconditions.checkArgument(cls2.isAssignableFrom(cls));
return resolve(type, cls, getGenericSupertype(type, cls, cls2));
}
static int hashCodeOrZero(Object obj) {
if (obj != null) {
return obj.hashCode();
}
return 0;
}
private static int indexOf(Object[] objArr, Object obj) {
int length = objArr.length;
for (int i = 0; i < length; i++) {
if (obj.equals(objArr[i])) {
return i;
}
}
throw new NoSuchElementException();
}
public static ParameterizedType newParameterizedTypeWithOwner(Type type, Type type2, Type... typeArr) {
return new ParameterizedTypeImpl(type, type2, typeArr);
}
public static Type resolve(Type type, Class<?> cls, Type type2) {
return resolve(type, cls, type2, new HashSet());
}
static Type resolveTypeVariable(Type type, Class<?> cls, TypeVariable<?> typeVariable) {
Class<?> declaringClassOf = declaringClassOf(typeVariable);
if (declaringClassOf == null) {
return typeVariable;
}
Type genericSupertype = getGenericSupertype(type, cls, declaringClassOf);
if (!(genericSupertype instanceof ParameterizedType)) {
return typeVariable;
}
return ((ParameterizedType) genericSupertype).getActualTypeArguments()[indexOf(declaringClassOf.getTypeParameters(), typeVariable)];
}
public static WildcardType subtypeOf(Type type) {
return new WildcardTypeImpl(type instanceof WildcardType ? ((WildcardType) type).getUpperBounds() : new Type[]{type}, EMPTY_TYPE_ARRAY);
}
public static WildcardType supertypeOf(Type type) {
return new WildcardTypeImpl(new Type[]{Object.class}, type instanceof WildcardType ? ((WildcardType) type).getLowerBounds() : new Type[]{type});
}
public static String typeToString(Type type) {
return type instanceof Class ? ((Class) type).getName() : type.toString();
}
private static Type resolve(Type type, Class<?> cls, Type type2, Collection<TypeVariable> collection) {
while (type2 instanceof TypeVariable) {
TypeVariable typeVariable = (TypeVariable) type2;
if (collection.contains(typeVariable)) {
return type2;
}
collection.add(typeVariable);
type2 = resolveTypeVariable(type, cls, typeVariable);
if (type2 == typeVariable) {
return type2;
}
}
if (type2 instanceof Class) {
Class cls2 = (Class) type2;
if (cls2.isArray()) {
Class<?> componentType = cls2.getComponentType();
Type resolve = resolve(type, cls, componentType, collection);
return componentType == resolve ? cls2 : arrayOf(resolve);
}
}
if (type2 instanceof GenericArrayType) {
GenericArrayType genericArrayType = (GenericArrayType) type2;
Type genericComponentType = genericArrayType.getGenericComponentType();
Type resolve2 = resolve(type, cls, genericComponentType, collection);
return genericComponentType == resolve2 ? genericArrayType : arrayOf(resolve2);
}
if (type2 instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type2;
Type ownerType = parameterizedType.getOwnerType();
Type resolve3 = resolve(type, cls, ownerType, collection);
boolean z = resolve3 != ownerType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
int length = actualTypeArguments.length;
for (int i = 0; i < length; i++) {
Type resolve4 = resolve(type, cls, actualTypeArguments[i], collection);
if (resolve4 != actualTypeArguments[i]) {
if (!z) {
actualTypeArguments = (Type[]) actualTypeArguments.clone();
z = true;
}
actualTypeArguments[i] = resolve4;
}
}
return z ? newParameterizedTypeWithOwner(resolve3, parameterizedType.getRawType(), actualTypeArguments) : parameterizedType;
}
boolean z2 = type2 instanceof WildcardType;
Type type3 = type2;
if (z2) {
WildcardType wildcardType = (WildcardType) type2;
Type[] lowerBounds = wildcardType.getLowerBounds();
Type[] upperBounds = wildcardType.getUpperBounds();
if (lowerBounds.length == 1) {
Type resolve5 = resolve(type, cls, lowerBounds[0], collection);
type3 = wildcardType;
if (resolve5 != lowerBounds[0]) {
return supertypeOf(resolve5);
}
} else {
type3 = wildcardType;
if (upperBounds.length == 1) {
Type resolve6 = resolve(type, cls, upperBounds[0], collection);
type3 = wildcardType;
if (resolve6 != upperBounds[0]) {
return subtypeOf(resolve6);
}
}
}
}
return type3;
}
}

View File

@@ -0,0 +1,176 @@
package com.google.gson.internal;
import com.google.gson.InstanceCreator;
import com.google.gson.JsonIOException;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
/* loaded from: classes.dex */
public final class ConstructorConstructor {
private final Map<Type, InstanceCreator<?>> instanceCreators;
public ConstructorConstructor(Map<Type, InstanceCreator<?>> map) {
this.instanceCreators = map;
}
private <T> ObjectConstructor<T> newDefaultConstructor(Class<? super T> cls) {
try {
final Constructor<? super T> declaredConstructor = cls.getDeclaredConstructor(new Class[0]);
if (!declaredConstructor.isAccessible()) {
declaredConstructor.setAccessible(true);
}
return new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.3
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
try {
return (T) declaredConstructor.newInstance(null);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (InstantiationException e2) {
throw new RuntimeException("Failed to invoke " + declaredConstructor + " with no args", e2);
} catch (InvocationTargetException e3) {
throw new RuntimeException("Failed to invoke " + declaredConstructor + " with no args", e3.getTargetException());
}
}
};
} catch (NoSuchMethodException unused) {
return null;
}
}
private <T> ObjectConstructor<T> newDefaultImplementationConstructor(final Type type, Class<? super T> cls) {
if (Collection.class.isAssignableFrom(cls)) {
return SortedSet.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.4
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new TreeSet();
}
} : EnumSet.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.5
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
Type type2 = type;
if (!(type2 instanceof ParameterizedType)) {
throw new JsonIOException("Invalid EnumSet type: " + type.toString());
}
Type type3 = ((ParameterizedType) type2).getActualTypeArguments()[0];
if (type3 instanceof Class) {
return (T) EnumSet.noneOf((Class) type3);
}
throw new JsonIOException("Invalid EnumSet type: " + type.toString());
}
} : Set.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.6
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new LinkedHashSet();
}
} : Queue.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.7
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new ArrayDeque();
}
} : new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.8
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new ArrayList();
}
};
}
if (Map.class.isAssignableFrom(cls)) {
return ConcurrentNavigableMap.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.9
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new ConcurrentSkipListMap();
}
} : ConcurrentMap.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.10
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new ConcurrentHashMap();
}
} : SortedMap.class.isAssignableFrom(cls) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.11
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new TreeMap();
}
} : (!(type instanceof ParameterizedType) || String.class.isAssignableFrom(TypeToken.get(((ParameterizedType) type).getActualTypeArguments()[0]).getRawType())) ? new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.13
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new LinkedTreeMap();
}
} : new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.12
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) new LinkedHashMap();
}
};
}
return null;
}
private <T> ObjectConstructor<T> newUnsafeAllocator(final Type type, final Class<? super T> cls) {
return new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.14
private final UnsafeAllocator unsafeAllocator = UnsafeAllocator.create();
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
try {
return (T) this.unsafeAllocator.newInstance(cls);
} catch (Exception e) {
throw new RuntimeException("Unable to invoke no-args constructor for " + type + ". Registering an InstanceCreator with Gson for this type may fix this problem.", e);
}
}
};
}
public <T> ObjectConstructor<T> get(TypeToken<T> typeToken) {
final Type type = typeToken.getType();
Class<? super T> rawType = typeToken.getRawType();
final InstanceCreator<?> instanceCreator = this.instanceCreators.get(type);
if (instanceCreator != null) {
return new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.1
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) instanceCreator.createInstance(type);
}
};
}
final InstanceCreator<?> instanceCreator2 = this.instanceCreators.get(rawType);
if (instanceCreator2 != null) {
return new ObjectConstructor<T>() { // from class: com.google.gson.internal.ConstructorConstructor.2
@Override // com.google.gson.internal.ObjectConstructor
public T construct() {
return (T) instanceCreator2.createInstance(type);
}
};
}
ObjectConstructor<T> newDefaultConstructor = newDefaultConstructor(rawType);
if (newDefaultConstructor != null) {
return newDefaultConstructor;
}
ObjectConstructor<T> newDefaultImplementationConstructor = newDefaultImplementationConstructor(type, rawType);
return newDefaultImplementationConstructor != null ? newDefaultImplementationConstructor : newUnsafeAllocator(type, rawType);
}
public String toString() {
return this.instanceCreators.toString();
}
}

View File

@@ -0,0 +1,190 @@
package com.google.gson.internal;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.Since;
import com.google.gson.annotations.Until;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class Excluder implements TypeAdapterFactory, Cloneable {
public static final Excluder DEFAULT = new Excluder();
private static final double IGNORE_VERSIONS = -1.0d;
private boolean requireExpose;
private double version = IGNORE_VERSIONS;
private int modifiers = 136;
private boolean serializeInnerClasses = true;
private List<ExclusionStrategy> serializationStrategies = Collections.emptyList();
private List<ExclusionStrategy> deserializationStrategies = Collections.emptyList();
private boolean isAnonymousOrLocal(Class<?> cls) {
return !Enum.class.isAssignableFrom(cls) && (cls.isAnonymousClass() || cls.isLocalClass());
}
private boolean isInnerClass(Class<?> cls) {
return cls.isMemberClass() && !isStatic(cls);
}
private boolean isStatic(Class<?> cls) {
return (cls.getModifiers() & 8) != 0;
}
private boolean isValidSince(Since since) {
return since == null || since.value() <= this.version;
}
private boolean isValidUntil(Until until) {
return until == null || until.value() > this.version;
}
private boolean isValidVersion(Since since, Until until) {
return isValidSince(since) && isValidUntil(until);
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
final boolean excludeClass = excludeClass(rawType, true);
final boolean excludeClass2 = excludeClass(rawType, false);
if (excludeClass || excludeClass2) {
return new TypeAdapter<T>() { // from class: com.google.gson.internal.Excluder.1
private TypeAdapter<T> delegate;
private TypeAdapter<T> delegate() {
TypeAdapter<T> typeAdapter = this.delegate;
if (typeAdapter != null) {
return typeAdapter;
}
TypeAdapter<T> delegateAdapter = gson.getDelegateAdapter(Excluder.this, typeToken);
this.delegate = delegateAdapter;
return delegateAdapter;
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
if (!excludeClass2) {
return delegate().read(jsonReader);
}
jsonReader.skipValue();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
if (excludeClass) {
jsonWriter.nullValue();
} else {
delegate().write(jsonWriter, t);
}
}
};
}
return null;
}
public Excluder disableInnerClassSerialization() {
Excluder m13clone = m13clone();
m13clone.serializeInnerClasses = false;
return m13clone;
}
public boolean excludeClass(Class<?> cls, boolean z) {
if (this.version != IGNORE_VERSIONS && !isValidVersion((Since) cls.getAnnotation(Since.class), (Until) cls.getAnnotation(Until.class))) {
return true;
}
if ((!this.serializeInnerClasses && isInnerClass(cls)) || isAnonymousOrLocal(cls)) {
return true;
}
Iterator<ExclusionStrategy> it = (z ? this.serializationStrategies : this.deserializationStrategies).iterator();
while (it.hasNext()) {
if (it.next().shouldSkipClass(cls)) {
return true;
}
}
return false;
}
public boolean excludeField(Field field, boolean z) {
Expose expose;
if ((this.modifiers & field.getModifiers()) != 0) {
return true;
}
if ((this.version != IGNORE_VERSIONS && !isValidVersion((Since) field.getAnnotation(Since.class), (Until) field.getAnnotation(Until.class))) || field.isSynthetic()) {
return true;
}
if (this.requireExpose && ((expose = (Expose) field.getAnnotation(Expose.class)) == null || (!z ? expose.deserialize() : expose.serialize()))) {
return true;
}
if ((!this.serializeInnerClasses && isInnerClass(field.getType())) || isAnonymousOrLocal(field.getType())) {
return true;
}
List<ExclusionStrategy> list = z ? this.serializationStrategies : this.deserializationStrategies;
if (list.isEmpty()) {
return false;
}
FieldAttributes fieldAttributes = new FieldAttributes(field);
Iterator<ExclusionStrategy> it = list.iterator();
while (it.hasNext()) {
if (it.next().shouldSkipField(fieldAttributes)) {
return true;
}
}
return false;
}
public Excluder excludeFieldsWithoutExposeAnnotation() {
Excluder m13clone = m13clone();
m13clone.requireExpose = true;
return m13clone;
}
public Excluder withExclusionStrategy(ExclusionStrategy exclusionStrategy, boolean z, boolean z2) {
Excluder m13clone = m13clone();
if (z) {
m13clone.serializationStrategies = new ArrayList(this.serializationStrategies);
m13clone.serializationStrategies.add(exclusionStrategy);
}
if (z2) {
m13clone.deserializationStrategies = new ArrayList(this.deserializationStrategies);
m13clone.deserializationStrategies.add(exclusionStrategy);
}
return m13clone;
}
public Excluder withModifiers(int... iArr) {
Excluder m13clone = m13clone();
m13clone.modifiers = 0;
for (int i : iArr) {
m13clone.modifiers = i | m13clone.modifiers;
}
return m13clone;
}
public Excluder withVersion(double d) {
Excluder m13clone = m13clone();
m13clone.version = d;
return m13clone;
}
/* JADX INFO: Access modifiers changed from: protected */
/* renamed from: clone, reason: merged with bridge method [inline-methods] */
public Excluder m13clone() {
try {
return (Excluder) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
}

View File

@@ -0,0 +1,11 @@
package com.google.gson.internal;
import com.google.gson.stream.JsonReader;
import java.io.IOException;
/* loaded from: classes.dex */
public abstract class JsonReaderInternalAccess {
public static JsonReaderInternalAccess INSTANCE;
public abstract void promoteNameToValue(JsonReader jsonReader) throws IOException;
}

View File

@@ -0,0 +1,69 @@
package com.google.gson.internal;
import java.io.ObjectStreamException;
import java.math.BigDecimal;
/* loaded from: classes.dex */
public final class LazilyParsedNumber extends Number {
private final String value;
public LazilyParsedNumber(String str) {
this.value = str;
}
private Object writeReplace() throws ObjectStreamException {
return new BigDecimal(this.value);
}
@Override // java.lang.Number
public double doubleValue() {
return Double.parseDouble(this.value);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof LazilyParsedNumber)) {
return false;
}
String str = this.value;
String str2 = ((LazilyParsedNumber) obj).value;
return str == str2 || str.equals(str2);
}
@Override // java.lang.Number
public float floatValue() {
return Float.parseFloat(this.value);
}
public int hashCode() {
return this.value.hashCode();
}
@Override // java.lang.Number
public int intValue() {
try {
try {
return Integer.parseInt(this.value);
} catch (NumberFormatException unused) {
return new BigDecimal(this.value).intValue();
}
} catch (NumberFormatException unused2) {
return (int) Long.parseLong(this.value);
}
}
@Override // java.lang.Number
public long longValue() {
try {
return Long.parseLong(this.value);
} catch (NumberFormatException unused) {
return new BigDecimal(this.value).longValue();
}
}
public String toString() {
return this.value;
}
}

View File

@@ -0,0 +1,770 @@
package com.google.gson.internal;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
/* loaded from: classes.dex */
public final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Serializable {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final Comparator<Comparable> NATURAL_ORDER = new Comparator<Comparable>() { // from class: com.google.gson.internal.LinkedHashTreeMap.1
@Override // java.util.Comparator
public int compare(Comparable comparable, Comparable comparable2) {
return comparable.compareTo(comparable2);
}
};
Comparator<? super K> comparator;
private LinkedHashTreeMap<K, V>.EntrySet entrySet;
final Node<K, V> header;
private LinkedHashTreeMap<K, V>.KeySet keySet;
int modCount;
int size;
Node<K, V>[] table;
int threshold;
static final class AvlBuilder<K, V> {
private int leavesSkipped;
private int leavesToSkip;
private int size;
private Node<K, V> stack;
AvlBuilder() {
}
void add(Node<K, V> node) {
node.right = null;
node.parent = null;
node.left = null;
node.height = 1;
int i = this.leavesToSkip;
if (i > 0) {
int i2 = this.size;
if ((i2 & 1) == 0) {
this.size = i2 + 1;
this.leavesToSkip = i - 1;
this.leavesSkipped++;
}
}
node.parent = this.stack;
this.stack = node;
this.size++;
int i3 = this.leavesToSkip;
if (i3 > 0) {
int i4 = this.size;
if ((i4 & 1) == 0) {
this.size = i4 + 1;
this.leavesToSkip = i3 - 1;
this.leavesSkipped++;
}
}
int i5 = 4;
while (true) {
int i6 = i5 - 1;
if ((this.size & i6) != i6) {
return;
}
int i7 = this.leavesSkipped;
if (i7 == 0) {
Node<K, V> node2 = this.stack;
Node<K, V> node3 = node2.parent;
Node<K, V> node4 = node3.parent;
node3.parent = node4.parent;
this.stack = node3;
node3.left = node4;
node3.right = node2;
node3.height = node2.height + 1;
node4.parent = node3;
node2.parent = node3;
} else if (i7 == 1) {
Node<K, V> node5 = this.stack;
Node<K, V> node6 = node5.parent;
this.stack = node6;
node6.right = node5;
node6.height = node5.height + 1;
node5.parent = node6;
this.leavesSkipped = 0;
} else if (i7 == 2) {
this.leavesSkipped = 0;
}
i5 *= 2;
}
}
void reset(int i) {
this.leavesToSkip = ((Integer.highestOneBit(i) * 2) - 1) - i;
this.size = 0;
this.leavesSkipped = 0;
this.stack = null;
}
Node<K, V> root() {
Node<K, V> node = this.stack;
if (node.parent == null) {
return node;
}
throw new IllegalStateException();
}
}
static class AvlIterator<K, V> {
private Node<K, V> stackTop;
AvlIterator() {
}
public Node<K, V> next() {
Node<K, V> node = this.stackTop;
if (node == null) {
return null;
}
Node<K, V> node2 = node.parent;
node.parent = null;
Node<K, V> node3 = node.right;
while (true) {
Node<K, V> node4 = node2;
node2 = node3;
if (node2 == null) {
this.stackTop = node4;
return node;
}
node2.parent = node4;
node3 = node2.left;
}
}
void reset(Node<K, V> node) {
Node<K, V> node2 = null;
while (true) {
Node<K, V> node3 = node2;
node2 = node;
if (node2 == null) {
this.stackTop = node3;
return;
} else {
node2.parent = node3;
node = node2.left;
}
}
}
}
final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
EntrySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
LinkedHashTreeMap.this.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return (obj instanceof Map.Entry) && LinkedHashTreeMap.this.findByEntry((Map.Entry) obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return new LinkedHashTreeMap<K, V>.LinkedTreeMapIterator<Map.Entry<K, V>>() { // from class: com.google.gson.internal.LinkedHashTreeMap.EntrySet.1
{
LinkedHashTreeMap linkedHashTreeMap = LinkedHashTreeMap.this;
}
@Override // java.util.Iterator
public Map.Entry<K, V> next() {
return nextNode();
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
Node<K, V> findByEntry;
if (!(obj instanceof Map.Entry) || (findByEntry = LinkedHashTreeMap.this.findByEntry((Map.Entry) obj)) == null) {
return false;
}
LinkedHashTreeMap.this.removeInternal(findByEntry, true);
return true;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return LinkedHashTreeMap.this.size;
}
}
final class KeySet extends AbstractSet<K> {
KeySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
LinkedHashTreeMap.this.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return LinkedHashTreeMap.this.containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<K> iterator() {
return new LinkedHashTreeMap<K, V>.LinkedTreeMapIterator<K>() { // from class: com.google.gson.internal.LinkedHashTreeMap.KeySet.1
{
LinkedHashTreeMap linkedHashTreeMap = LinkedHashTreeMap.this;
}
@Override // java.util.Iterator
public K next() {
return nextNode().key;
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
return LinkedHashTreeMap.this.removeInternalByKey(obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return LinkedHashTreeMap.this.size;
}
}
private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
int expectedModCount;
Node<K, V> lastReturned;
Node<K, V> next;
LinkedTreeMapIterator() {
LinkedHashTreeMap linkedHashTreeMap = LinkedHashTreeMap.this;
this.next = linkedHashTreeMap.header.next;
this.lastReturned = null;
this.expectedModCount = linkedHashTreeMap.modCount;
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.next != LinkedHashTreeMap.this.header;
}
final Node<K, V> nextNode() {
Node<K, V> node = this.next;
LinkedHashTreeMap linkedHashTreeMap = LinkedHashTreeMap.this;
if (node == linkedHashTreeMap.header) {
throw new NoSuchElementException();
}
if (linkedHashTreeMap.modCount != this.expectedModCount) {
throw new ConcurrentModificationException();
}
this.next = node.next;
this.lastReturned = node;
return node;
}
@Override // java.util.Iterator
public final void remove() {
Node<K, V> node = this.lastReturned;
if (node == null) {
throw new IllegalStateException();
}
LinkedHashTreeMap.this.removeInternal(node, true);
this.lastReturned = null;
this.expectedModCount = LinkedHashTreeMap.this.modCount;
}
}
public LinkedHashTreeMap() {
this(NATURAL_ORDER);
}
private void doubleCapacity() {
this.table = doubleCapacity(this.table);
Node<K, V>[] nodeArr = this.table;
this.threshold = (nodeArr.length / 2) + (nodeArr.length / 4);
}
private boolean equal(Object obj, Object obj2) {
return obj == obj2 || (obj != null && obj.equals(obj2));
}
private void rebalance(Node<K, V> node, boolean z) {
while (node != null) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
int i = node2 != null ? node2.height : 0;
int i2 = node3 != null ? node3.height : 0;
int i3 = i - i2;
if (i3 == -2) {
Node<K, V> node4 = node3.left;
Node<K, V> node5 = node3.right;
int i4 = (node4 != null ? node4.height : 0) - (node5 != null ? node5.height : 0);
if (i4 == -1 || (i4 == 0 && !z)) {
rotateLeft(node);
} else {
rotateRight(node3);
rotateLeft(node);
}
if (z) {
return;
}
} else if (i3 == 2) {
Node<K, V> node6 = node2.left;
Node<K, V> node7 = node2.right;
int i5 = (node6 != null ? node6.height : 0) - (node7 != null ? node7.height : 0);
if (i5 == 1 || (i5 == 0 && !z)) {
rotateRight(node);
} else {
rotateLeft(node2);
rotateRight(node);
}
if (z) {
return;
}
} else if (i3 == 0) {
node.height = i + 1;
if (z) {
return;
}
} else {
node.height = Math.max(i, i2) + 1;
if (!z) {
return;
}
}
node = node.parent;
}
}
private void replaceInParent(Node<K, V> node, Node<K, V> node2) {
Node<K, V> node3 = node.parent;
node.parent = null;
if (node2 != null) {
node2.parent = node3;
}
if (node3 == null) {
int i = node.hash;
this.table[i & (r0.length - 1)] = node2;
} else if (node3.left == node) {
node3.left = node2;
} else {
node3.right = node2;
}
}
private void rotateLeft(Node<K, V> node) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
Node<K, V> node4 = node3.left;
Node<K, V> node5 = node3.right;
node.right = node4;
if (node4 != null) {
node4.parent = node;
}
replaceInParent(node, node3);
node3.left = node;
node.parent = node3;
node.height = Math.max(node2 != null ? node2.height : 0, node4 != null ? node4.height : 0) + 1;
node3.height = Math.max(node.height, node5 != null ? node5.height : 0) + 1;
}
private void rotateRight(Node<K, V> node) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
Node<K, V> node4 = node2.left;
Node<K, V> node5 = node2.right;
node.left = node5;
if (node5 != null) {
node5.parent = node;
}
replaceInParent(node, node2);
node2.right = node;
node.parent = node2;
node.height = Math.max(node3 != null ? node3.height : 0, node5 != null ? node5.height : 0) + 1;
node2.height = Math.max(node.height, node4 != null ? node4.height : 0) + 1;
}
private static int secondaryHash(int i) {
int i2 = i ^ ((i >>> 20) ^ (i >>> 12));
return (i2 >>> 4) ^ ((i2 >>> 7) ^ i2);
}
private Object writeReplace() throws ObjectStreamException {
return new LinkedHashMap(this);
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
Arrays.fill(this.table, (Object) null);
this.size = 0;
this.modCount++;
Node<K, V> node = this.header;
Node<K, V> node2 = node.next;
while (node2 != node) {
Node<K, V> node3 = node2.next;
node2.prev = null;
node2.next = null;
node2 = node3;
}
node.prev = node;
node.next = node;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return findByObject(obj) != null;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
LinkedHashTreeMap<K, V>.EntrySet entrySet = this.entrySet;
if (entrySet != null) {
return entrySet;
}
LinkedHashTreeMap<K, V>.EntrySet entrySet2 = new EntrySet();
this.entrySet = entrySet2;
return entrySet2;
}
Node<K, V> find(K k, boolean z) {
Node<K, V> node;
int i;
Node<K, V> node2;
Comparator<? super K> comparator = this.comparator;
Node<K, V>[] nodeArr = this.table;
int secondaryHash = secondaryHash(k.hashCode());
int length = (nodeArr.length - 1) & secondaryHash;
Node<K, V> node3 = nodeArr[length];
if (node3 != null) {
Comparable comparable = comparator == NATURAL_ORDER ? (Comparable) k : null;
while (true) {
int compareTo = comparable != null ? comparable.compareTo(node3.key) : comparator.compare(k, node3.key);
if (compareTo == 0) {
return node3;
}
Node<K, V> node4 = compareTo < 0 ? node3.left : node3.right;
if (node4 == null) {
node = node3;
i = compareTo;
break;
}
node3 = node4;
}
} else {
node = node3;
i = 0;
}
if (!z) {
return null;
}
Node<K, V> node5 = this.header;
if (node != null) {
node2 = new Node<>(node, k, secondaryHash, node5, node5.prev);
if (i < 0) {
node.left = node2;
} else {
node.right = node2;
}
rebalance(node, true);
} else {
if (comparator == NATURAL_ORDER && !(k instanceof Comparable)) {
throw new ClassCastException(k.getClass().getName() + " is not Comparable");
}
node2 = new Node<>(node, k, secondaryHash, node5, node5.prev);
nodeArr[length] = node2;
}
int i2 = this.size;
this.size = i2 + 1;
if (i2 > this.threshold) {
doubleCapacity();
}
this.modCount++;
return node2;
}
Node<K, V> findByEntry(Map.Entry<?, ?> entry) {
Node<K, V> findByObject = findByObject(entry.getKey());
if (findByObject != null && equal(findByObject.value, entry.getValue())) {
return findByObject;
}
return null;
}
/* JADX WARN: Multi-variable type inference failed */
Node<K, V> findByObject(Object obj) {
if (obj == 0) {
return null;
}
try {
return find(obj, false);
} catch (ClassCastException unused) {
return null;
}
}
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
Node<K, V> findByObject = findByObject(obj);
if (findByObject != null) {
return findByObject.value;
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
LinkedHashTreeMap<K, V>.KeySet keySet = this.keySet;
if (keySet != null) {
return keySet;
}
LinkedHashTreeMap<K, V>.KeySet keySet2 = new KeySet();
this.keySet = keySet2;
return keySet2;
}
@Override // java.util.AbstractMap, java.util.Map
public V put(K k, V v) {
if (k == null) {
throw new NullPointerException("key == null");
}
Node<K, V> find = find(k, true);
V v2 = find.value;
find.value = v;
return v2;
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
Node<K, V> removeInternalByKey = removeInternalByKey(obj);
if (removeInternalByKey != null) {
return removeInternalByKey.value;
}
return null;
}
void removeInternal(Node<K, V> node, boolean z) {
int i;
if (z) {
Node<K, V> node2 = node.prev;
node2.next = node.next;
node.next.prev = node2;
node.prev = null;
node.next = null;
}
Node<K, V> node3 = node.left;
Node<K, V> node4 = node.right;
Node<K, V> node5 = node.parent;
int i2 = 0;
if (node3 == null || node4 == null) {
if (node3 != null) {
replaceInParent(node, node3);
node.left = null;
} else if (node4 != null) {
replaceInParent(node, node4);
node.right = null;
} else {
replaceInParent(node, null);
}
rebalance(node5, false);
this.size--;
this.modCount++;
return;
}
Node<K, V> last = node3.height > node4.height ? node3.last() : node4.first();
removeInternal(last, false);
Node<K, V> node6 = node.left;
if (node6 != null) {
i = node6.height;
last.left = node6;
node6.parent = last;
node.left = null;
} else {
i = 0;
}
Node<K, V> node7 = node.right;
if (node7 != null) {
i2 = node7.height;
last.right = node7;
node7.parent = last;
node.right = null;
}
last.height = Math.max(i, i2) + 1;
replaceInParent(node, last);
}
Node<K, V> removeInternalByKey(Object obj) {
Node<K, V> findByObject = findByObject(obj);
if (findByObject != null) {
removeInternal(findByObject, true);
}
return findByObject;
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return this.size;
}
public LinkedHashTreeMap(Comparator<? super K> comparator) {
this.size = 0;
this.modCount = 0;
this.comparator = comparator == null ? NATURAL_ORDER : comparator;
this.header = new Node<>();
this.table = new Node[16];
Node<K, V>[] nodeArr = this.table;
this.threshold = (nodeArr.length / 2) + (nodeArr.length / 4);
}
static <K, V> Node<K, V>[] doubleCapacity(Node<K, V>[] nodeArr) {
int length = nodeArr.length;
Node<K, V>[] nodeArr2 = new Node[length * 2];
AvlIterator avlIterator = new AvlIterator();
AvlBuilder avlBuilder = new AvlBuilder();
AvlBuilder avlBuilder2 = new AvlBuilder();
for (int i = 0; i < length; i++) {
Node<K, V> node = nodeArr[i];
if (node != null) {
avlIterator.reset(node);
int i2 = 0;
int i3 = 0;
while (true) {
Node<K, V> next = avlIterator.next();
if (next == null) {
break;
}
if ((next.hash & length) == 0) {
i2++;
} else {
i3++;
}
}
avlBuilder.reset(i2);
avlBuilder2.reset(i3);
avlIterator.reset(node);
while (true) {
Node<K, V> next2 = avlIterator.next();
if (next2 == null) {
break;
}
if ((next2.hash & length) == 0) {
avlBuilder.add(next2);
} else {
avlBuilder2.add(next2);
}
}
nodeArr2[i] = i2 > 0 ? avlBuilder.root() : null;
nodeArr2[i + length] = i3 > 0 ? avlBuilder2.root() : null;
}
}
return nodeArr2;
}
static final class Node<K, V> implements Map.Entry<K, V> {
final int hash;
int height;
final K key;
Node<K, V> left;
Node<K, V> next;
Node<K, V> parent;
Node<K, V> prev;
Node<K, V> right;
V value;
Node() {
this.key = null;
this.hash = -1;
this.prev = this;
this.next = this;
}
@Override // java.util.Map.Entry
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
K k = this.key;
if (k == null) {
if (entry.getKey() != null) {
return false;
}
} else if (!k.equals(entry.getKey())) {
return false;
}
V v = this.value;
if (v == null) {
if (entry.getValue() != null) {
return false;
}
} else if (!v.equals(entry.getValue())) {
return false;
}
return true;
}
public Node<K, V> first() {
Node<K, V> node = this;
for (Node<K, V> node2 = this.left; node2 != null; node2 = node2.left) {
node = node2;
}
return node;
}
@Override // java.util.Map.Entry
public K getKey() {
return this.key;
}
@Override // java.util.Map.Entry
public V getValue() {
return this.value;
}
@Override // java.util.Map.Entry
public int hashCode() {
K k = this.key;
int hashCode = k == null ? 0 : k.hashCode();
V v = this.value;
return hashCode ^ (v != null ? v.hashCode() : 0);
}
public Node<K, V> last() {
Node<K, V> node = this;
for (Node<K, V> node2 = this.right; node2 != null; node2 = node2.right) {
node = node2;
}
return node;
}
@Override // java.util.Map.Entry
public V setValue(V v) {
V v2 = this.value;
this.value = v;
return v2;
}
public String toString() {
return this.key + "=" + this.value;
}
Node(Node<K, V> node, K k, int i, Node<K, V> node2, Node<K, V> node3) {
this.parent = node;
this.key = k;
this.hash = i;
this.height = 1;
this.next = node2;
this.prev = node3;
node3.next = this;
node2.prev = this;
}
}
}

View File

@@ -0,0 +1,560 @@
package com.google.gson.internal;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
/* loaded from: classes.dex */
public final class LinkedTreeMap<K, V> extends AbstractMap<K, V> implements Serializable {
static final /* synthetic */ boolean $assertionsDisabled = false;
private static final Comparator<Comparable> NATURAL_ORDER = new Comparator<Comparable>() { // from class: com.google.gson.internal.LinkedTreeMap.1
@Override // java.util.Comparator
public int compare(Comparable comparable, Comparable comparable2) {
return comparable.compareTo(comparable2);
}
};
Comparator<? super K> comparator;
private LinkedTreeMap<K, V>.EntrySet entrySet;
final Node<K, V> header;
private LinkedTreeMap<K, V>.KeySet keySet;
int modCount;
Node<K, V> root;
int size;
class EntrySet extends AbstractSet<Map.Entry<K, V>> {
EntrySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
LinkedTreeMap.this.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return (obj instanceof Map.Entry) && LinkedTreeMap.this.findByEntry((Map.Entry) obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<Map.Entry<K, V>> iterator() {
return new LinkedTreeMap<K, V>.LinkedTreeMapIterator<Map.Entry<K, V>>() { // from class: com.google.gson.internal.LinkedTreeMap.EntrySet.1
{
LinkedTreeMap linkedTreeMap = LinkedTreeMap.this;
}
@Override // java.util.Iterator
public Map.Entry<K, V> next() {
return nextNode();
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
Node<K, V> findByEntry;
if (!(obj instanceof Map.Entry) || (findByEntry = LinkedTreeMap.this.findByEntry((Map.Entry) obj)) == null) {
return false;
}
LinkedTreeMap.this.removeInternal(findByEntry, true);
return true;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return LinkedTreeMap.this.size;
}
}
final class KeySet extends AbstractSet<K> {
KeySet() {
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public void clear() {
LinkedTreeMap.this.clear();
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(Object obj) {
return LinkedTreeMap.this.containsKey(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public Iterator<K> iterator() {
return new LinkedTreeMap<K, V>.LinkedTreeMapIterator<K>() { // from class: com.google.gson.internal.LinkedTreeMap.KeySet.1
{
LinkedTreeMap linkedTreeMap = LinkedTreeMap.this;
}
@Override // java.util.Iterator
public K next() {
return nextNode().key;
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean remove(Object obj) {
return LinkedTreeMap.this.removeInternalByKey(obj) != null;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return LinkedTreeMap.this.size;
}
}
private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
int expectedModCount;
Node<K, V> lastReturned;
Node<K, V> next;
LinkedTreeMapIterator() {
LinkedTreeMap linkedTreeMap = LinkedTreeMap.this;
this.next = linkedTreeMap.header.next;
this.lastReturned = null;
this.expectedModCount = linkedTreeMap.modCount;
}
@Override // java.util.Iterator
public final boolean hasNext() {
return this.next != LinkedTreeMap.this.header;
}
final Node<K, V> nextNode() {
Node<K, V> node = this.next;
LinkedTreeMap linkedTreeMap = LinkedTreeMap.this;
if (node == linkedTreeMap.header) {
throw new NoSuchElementException();
}
if (linkedTreeMap.modCount != this.expectedModCount) {
throw new ConcurrentModificationException();
}
this.next = node.next;
this.lastReturned = node;
return node;
}
@Override // java.util.Iterator
public final void remove() {
Node<K, V> node = this.lastReturned;
if (node == null) {
throw new IllegalStateException();
}
LinkedTreeMap.this.removeInternal(node, true);
this.lastReturned = null;
this.expectedModCount = LinkedTreeMap.this.modCount;
}
}
public LinkedTreeMap() {
this(NATURAL_ORDER);
}
private boolean equal(Object obj, Object obj2) {
return obj == obj2 || (obj != null && obj.equals(obj2));
}
private void rebalance(Node<K, V> node, boolean z) {
while (node != null) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
int i = node2 != null ? node2.height : 0;
int i2 = node3 != null ? node3.height : 0;
int i3 = i - i2;
if (i3 == -2) {
Node<K, V> node4 = node3.left;
Node<K, V> node5 = node3.right;
int i4 = (node4 != null ? node4.height : 0) - (node5 != null ? node5.height : 0);
if (i4 == -1 || (i4 == 0 && !z)) {
rotateLeft(node);
} else {
rotateRight(node3);
rotateLeft(node);
}
if (z) {
return;
}
} else if (i3 == 2) {
Node<K, V> node6 = node2.left;
Node<K, V> node7 = node2.right;
int i5 = (node6 != null ? node6.height : 0) - (node7 != null ? node7.height : 0);
if (i5 == 1 || (i5 == 0 && !z)) {
rotateRight(node);
} else {
rotateLeft(node2);
rotateRight(node);
}
if (z) {
return;
}
} else if (i3 == 0) {
node.height = i + 1;
if (z) {
return;
}
} else {
node.height = Math.max(i, i2) + 1;
if (!z) {
return;
}
}
node = node.parent;
}
}
private void replaceInParent(Node<K, V> node, Node<K, V> node2) {
Node<K, V> node3 = node.parent;
node.parent = null;
if (node2 != null) {
node2.parent = node3;
}
if (node3 == null) {
this.root = node2;
} else if (node3.left == node) {
node3.left = node2;
} else {
node3.right = node2;
}
}
private void rotateLeft(Node<K, V> node) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
Node<K, V> node4 = node3.left;
Node<K, V> node5 = node3.right;
node.right = node4;
if (node4 != null) {
node4.parent = node;
}
replaceInParent(node, node3);
node3.left = node;
node.parent = node3;
node.height = Math.max(node2 != null ? node2.height : 0, node4 != null ? node4.height : 0) + 1;
node3.height = Math.max(node.height, node5 != null ? node5.height : 0) + 1;
}
private void rotateRight(Node<K, V> node) {
Node<K, V> node2 = node.left;
Node<K, V> node3 = node.right;
Node<K, V> node4 = node2.left;
Node<K, V> node5 = node2.right;
node.left = node5;
if (node5 != null) {
node5.parent = node;
}
replaceInParent(node, node2);
node2.right = node;
node.parent = node2;
node.height = Math.max(node3 != null ? node3.height : 0, node5 != null ? node5.height : 0) + 1;
node2.height = Math.max(node.height, node4 != null ? node4.height : 0) + 1;
}
private Object writeReplace() throws ObjectStreamException {
return new LinkedHashMap(this);
}
@Override // java.util.AbstractMap, java.util.Map
public void clear() {
this.root = null;
this.size = 0;
this.modCount++;
Node<K, V> node = this.header;
node.prev = node;
node.next = node;
}
@Override // java.util.AbstractMap, java.util.Map
public boolean containsKey(Object obj) {
return findByObject(obj) != null;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<Map.Entry<K, V>> entrySet() {
LinkedTreeMap<K, V>.EntrySet entrySet = this.entrySet;
if (entrySet != null) {
return entrySet;
}
LinkedTreeMap<K, V>.EntrySet entrySet2 = new EntrySet();
this.entrySet = entrySet2;
return entrySet2;
}
Node<K, V> find(K k, boolean z) {
int i;
Node<K, V> node;
Comparator<? super K> comparator = this.comparator;
Node<K, V> node2 = this.root;
if (node2 != null) {
Comparable comparable = comparator == NATURAL_ORDER ? (Comparable) k : null;
while (true) {
i = comparable != null ? comparable.compareTo(node2.key) : comparator.compare(k, node2.key);
if (i == 0) {
return node2;
}
Node<K, V> node3 = i < 0 ? node2.left : node2.right;
if (node3 == null) {
break;
}
node2 = node3;
}
} else {
i = 0;
}
if (!z) {
return null;
}
Node<K, V> node4 = this.header;
if (node2 != null) {
node = new Node<>(node2, k, node4, node4.prev);
if (i < 0) {
node2.left = node;
} else {
node2.right = node;
}
rebalance(node2, true);
} else {
if (comparator == NATURAL_ORDER && !(k instanceof Comparable)) {
throw new ClassCastException(k.getClass().getName() + " is not Comparable");
}
node = new Node<>(node2, k, node4, node4.prev);
this.root = node;
}
this.size++;
this.modCount++;
return node;
}
Node<K, V> findByEntry(Map.Entry<?, ?> entry) {
Node<K, V> findByObject = findByObject(entry.getKey());
if (findByObject != null && equal(findByObject.value, entry.getValue())) {
return findByObject;
}
return null;
}
/* JADX WARN: Multi-variable type inference failed */
Node<K, V> findByObject(Object obj) {
if (obj == 0) {
return null;
}
try {
return find(obj, false);
} catch (ClassCastException unused) {
return null;
}
}
@Override // java.util.AbstractMap, java.util.Map
public V get(Object obj) {
Node<K, V> findByObject = findByObject(obj);
if (findByObject != null) {
return findByObject.value;
}
return null;
}
@Override // java.util.AbstractMap, java.util.Map
public Set<K> keySet() {
LinkedTreeMap<K, V>.KeySet keySet = this.keySet;
if (keySet != null) {
return keySet;
}
LinkedTreeMap<K, V>.KeySet keySet2 = new KeySet();
this.keySet = keySet2;
return keySet2;
}
@Override // java.util.AbstractMap, java.util.Map
public V put(K k, V v) {
if (k == null) {
throw new NullPointerException("key == null");
}
Node<K, V> find = find(k, true);
V v2 = find.value;
find.value = v;
return v2;
}
@Override // java.util.AbstractMap, java.util.Map
public V remove(Object obj) {
Node<K, V> removeInternalByKey = removeInternalByKey(obj);
if (removeInternalByKey != null) {
return removeInternalByKey.value;
}
return null;
}
void removeInternal(Node<K, V> node, boolean z) {
int i;
if (z) {
Node<K, V> node2 = node.prev;
node2.next = node.next;
node.next.prev = node2;
}
Node<K, V> node3 = node.left;
Node<K, V> node4 = node.right;
Node<K, V> node5 = node.parent;
int i2 = 0;
if (node3 == null || node4 == null) {
if (node3 != null) {
replaceInParent(node, node3);
node.left = null;
} else if (node4 != null) {
replaceInParent(node, node4);
node.right = null;
} else {
replaceInParent(node, null);
}
rebalance(node5, false);
this.size--;
this.modCount++;
return;
}
Node<K, V> last = node3.height > node4.height ? node3.last() : node4.first();
removeInternal(last, false);
Node<K, V> node6 = node.left;
if (node6 != null) {
i = node6.height;
last.left = node6;
node6.parent = last;
node.left = null;
} else {
i = 0;
}
Node<K, V> node7 = node.right;
if (node7 != null) {
i2 = node7.height;
last.right = node7;
node7.parent = last;
node.right = null;
}
last.height = Math.max(i, i2) + 1;
replaceInParent(node, last);
}
Node<K, V> removeInternalByKey(Object obj) {
Node<K, V> findByObject = findByObject(obj);
if (findByObject != null) {
removeInternal(findByObject, true);
}
return findByObject;
}
@Override // java.util.AbstractMap, java.util.Map
public int size() {
return this.size;
}
public LinkedTreeMap(Comparator<? super K> comparator) {
this.size = 0;
this.modCount = 0;
this.header = new Node<>();
this.comparator = comparator == null ? NATURAL_ORDER : comparator;
}
static final class Node<K, V> implements Map.Entry<K, V> {
int height;
final K key;
Node<K, V> left;
Node<K, V> next;
Node<K, V> parent;
Node<K, V> prev;
Node<K, V> right;
V value;
Node() {
this.key = null;
this.prev = this;
this.next = this;
}
@Override // java.util.Map.Entry
public boolean equals(Object obj) {
if (!(obj instanceof Map.Entry)) {
return false;
}
Map.Entry entry = (Map.Entry) obj;
K k = this.key;
if (k == null) {
if (entry.getKey() != null) {
return false;
}
} else if (!k.equals(entry.getKey())) {
return false;
}
V v = this.value;
if (v == null) {
if (entry.getValue() != null) {
return false;
}
} else if (!v.equals(entry.getValue())) {
return false;
}
return true;
}
public Node<K, V> first() {
Node<K, V> node = this;
for (Node<K, V> node2 = this.left; node2 != null; node2 = node2.left) {
node = node2;
}
return node;
}
@Override // java.util.Map.Entry
public K getKey() {
return this.key;
}
@Override // java.util.Map.Entry
public V getValue() {
return this.value;
}
@Override // java.util.Map.Entry
public int hashCode() {
K k = this.key;
int hashCode = k == null ? 0 : k.hashCode();
V v = this.value;
return hashCode ^ (v != null ? v.hashCode() : 0);
}
public Node<K, V> last() {
Node<K, V> node = this;
for (Node<K, V> node2 = this.right; node2 != null; node2 = node2.right) {
node = node2;
}
return node;
}
@Override // java.util.Map.Entry
public V setValue(V v) {
V v2 = this.value;
this.value = v;
return v2;
}
public String toString() {
return this.key + "=" + this.value;
}
Node(Node<K, V> node, K k, Node<K, V> node2, Node<K, V> node3) {
this.parent = node;
this.key = k;
this.height = 1;
this.next = node2;
this.prev = node3;
node3.next = this;
node2.prev = this;
}
}
}

View File

@@ -0,0 +1,6 @@
package com.google.gson.internal;
/* loaded from: classes.dex */
public interface ObjectConstructor<T> {
T construct();
}

View File

@@ -0,0 +1,55 @@
package com.google.gson.internal;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes.dex */
public final class Primitives {
private static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_TYPE;
private static final Map<Class<?>, Class<?>> WRAPPER_TO_PRIMITIVE_TYPE;
static {
HashMap hashMap = new HashMap(16);
HashMap hashMap2 = new HashMap(16);
add(hashMap, hashMap2, Boolean.TYPE, Boolean.class);
add(hashMap, hashMap2, Byte.TYPE, Byte.class);
add(hashMap, hashMap2, Character.TYPE, Character.class);
add(hashMap, hashMap2, Double.TYPE, Double.class);
add(hashMap, hashMap2, Float.TYPE, Float.class);
add(hashMap, hashMap2, Integer.TYPE, Integer.class);
add(hashMap, hashMap2, Long.TYPE, Long.class);
add(hashMap, hashMap2, Short.TYPE, Short.class);
add(hashMap, hashMap2, Void.TYPE, Void.class);
PRIMITIVE_TO_WRAPPER_TYPE = Collections.unmodifiableMap(hashMap);
WRAPPER_TO_PRIMITIVE_TYPE = Collections.unmodifiableMap(hashMap2);
}
private Primitives() {
throw new UnsupportedOperationException();
}
private static void add(Map<Class<?>, Class<?>> map, Map<Class<?>, Class<?>> map2, Class<?> cls, Class<?> cls2) {
map.put(cls, cls2);
map2.put(cls2, cls);
}
public static boolean isPrimitive(Type type) {
return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type);
}
public static boolean isWrapperType(Type type) {
return WRAPPER_TO_PRIMITIVE_TYPE.containsKey(C$Gson$Preconditions.checkNotNull(type));
}
public static <T> Class<T> unwrap(Class<T> cls) {
Class<T> cls2 = (Class) WRAPPER_TO_PRIMITIVE_TYPE.get(C$Gson$Preconditions.checkNotNull(cls));
return cls2 == null ? cls : cls2;
}
public static <T> Class<T> wrap(Class<T> cls) {
Class<T> cls2 = (Class) PRIMITIVE_TO_WRAPPER_TYPE.get(C$Gson$Preconditions.checkNotNull(cls));
return cls2 == null ? cls : cls2;
}
}

View File

@@ -0,0 +1,108 @@
package com.google.gson.internal;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.JsonNull;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.internal.bind.TypeAdapters;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.stream.MalformedJsonException;
import java.io.EOFException;
import java.io.IOException;
import java.io.Writer;
/* loaded from: classes.dex */
public final class Streams {
private Streams() {
throw new UnsupportedOperationException();
}
public static JsonElement parse(JsonReader jsonReader) throws JsonParseException {
boolean z;
try {
try {
jsonReader.peek();
z = false;
try {
return TypeAdapters.JSON_ELEMENT.read(jsonReader);
} catch (EOFException e) {
e = e;
if (z) {
return JsonNull.INSTANCE;
}
throw new JsonSyntaxException(e);
}
} catch (MalformedJsonException e2) {
throw new JsonSyntaxException(e2);
} catch (IOException e3) {
throw new JsonIOException(e3);
} catch (NumberFormatException e4) {
throw new JsonSyntaxException(e4);
}
} catch (EOFException e5) {
e = e5;
z = true;
}
}
public static void write(JsonElement jsonElement, JsonWriter jsonWriter) throws IOException {
TypeAdapters.JSON_ELEMENT.write(jsonWriter, jsonElement);
}
public static Writer writerForAppendable(Appendable appendable) {
return appendable instanceof Writer ? (Writer) appendable : new AppendableWriter(appendable);
}
private static final class AppendableWriter extends Writer {
private final Appendable appendable;
private final CurrentWrite currentWrite = new CurrentWrite();
static class CurrentWrite implements CharSequence {
char[] chars;
CurrentWrite() {
}
@Override // java.lang.CharSequence
public char charAt(int i) {
return this.chars[i];
}
@Override // java.lang.CharSequence
public int length() {
return this.chars.length;
}
@Override // java.lang.CharSequence
public CharSequence subSequence(int i, int i2) {
return new String(this.chars, i, i2 - i);
}
}
AppendableWriter(Appendable appendable) {
this.appendable = appendable;
}
@Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
public void close() {
}
@Override // java.io.Writer, java.io.Flushable
public void flush() {
}
@Override // java.io.Writer
public void write(char[] cArr, int i, int i2) throws IOException {
CurrentWrite currentWrite = this.currentWrite;
currentWrite.chars = cArr;
this.appendable.append(currentWrite, i, i2 + i);
}
@Override // java.io.Writer
public void write(int i) throws IOException {
this.appendable.append((char) i);
}
}
}

View File

@@ -0,0 +1,73 @@
package com.google.gson.internal;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/* loaded from: classes.dex */
public abstract class UnsafeAllocator {
static void assertInstantiable(Class<?> cls) {
int modifiers = cls.getModifiers();
if (Modifier.isInterface(modifiers)) {
throw new UnsupportedOperationException("Interface can't be instantiated! Interface name: " + cls.getName());
}
if (Modifier.isAbstract(modifiers)) {
throw new UnsupportedOperationException("Abstract class can't be instantiated! Class name: " + cls.getName());
}
}
public static UnsafeAllocator create() {
try {
Class<?> cls = Class.forName("sun.misc.Unsafe");
Field declaredField = cls.getDeclaredField("theUnsafe");
declaredField.setAccessible(true);
final Object obj = declaredField.get(null);
final Method method = cls.getMethod("allocateInstance", Class.class);
return new UnsafeAllocator() { // from class: com.google.gson.internal.UnsafeAllocator.1
@Override // com.google.gson.internal.UnsafeAllocator
public <T> T newInstance(Class<T> cls2) throws Exception {
UnsafeAllocator.assertInstantiable(cls2);
return (T) method.invoke(obj, cls2);
}
};
} catch (Exception unused) {
try {
try {
Method declaredMethod = ObjectStreamClass.class.getDeclaredMethod("getConstructorId", Class.class);
declaredMethod.setAccessible(true);
final int intValue = ((Integer) declaredMethod.invoke(null, Object.class)).intValue();
final Method declaredMethod2 = ObjectStreamClass.class.getDeclaredMethod("newInstance", Class.class, Integer.TYPE);
declaredMethod2.setAccessible(true);
return new UnsafeAllocator() { // from class: com.google.gson.internal.UnsafeAllocator.2
@Override // com.google.gson.internal.UnsafeAllocator
public <T> T newInstance(Class<T> cls2) throws Exception {
UnsafeAllocator.assertInstantiable(cls2);
return (T) declaredMethod2.invoke(null, cls2, Integer.valueOf(intValue));
}
};
} catch (Exception unused2) {
final Method declaredMethod3 = ObjectInputStream.class.getDeclaredMethod("newInstance", Class.class, Class.class);
declaredMethod3.setAccessible(true);
return new UnsafeAllocator() { // from class: com.google.gson.internal.UnsafeAllocator.3
@Override // com.google.gson.internal.UnsafeAllocator
public <T> T newInstance(Class<T> cls2) throws Exception {
UnsafeAllocator.assertInstantiable(cls2);
return (T) declaredMethod3.invoke(null, cls2, Object.class);
}
};
}
} catch (Exception unused3) {
return new UnsafeAllocator() { // from class: com.google.gson.internal.UnsafeAllocator.4
@Override // com.google.gson.internal.UnsafeAllocator
public <T> T newInstance(Class<T> cls2) {
throw new UnsupportedOperationException("Cannot allocate " + cls2);
}
};
}
}
}
public abstract <T> T newInstance(Class<T> cls) throws Exception;
}

View File

@@ -0,0 +1,71 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.C$Gson$Types;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
import java.util.ArrayList;
/* loaded from: classes.dex */
public final class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.ArrayTypeAdapter.1
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
if (!(type instanceof GenericArrayType) && (!(type instanceof Class) || !((Class) type).isArray())) {
return null;
}
Type arrayComponentType = C$Gson$Types.getArrayComponentType(type);
return new ArrayTypeAdapter(gson, gson.getAdapter(TypeToken.get(arrayComponentType)), C$Gson$Types.getRawType(arrayComponentType));
}
};
private final Class<E> componentType;
private final TypeAdapter<E> componentTypeAdapter;
public ArrayTypeAdapter(Gson gson, TypeAdapter<E> typeAdapter, Class<E> cls) {
this.componentTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, cls);
this.componentType = cls;
}
@Override // com.google.gson.TypeAdapter
public Object read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
ArrayList arrayList = new ArrayList();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
arrayList.add(this.componentTypeAdapter.read(jsonReader));
}
jsonReader.endArray();
int size = arrayList.size();
Object newInstance = Array.newInstance((Class<?>) this.componentType, size);
for (int i = 0; i < size; i++) {
Array.set(newInstance, i, arrayList.get(i));
}
return newInstance;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Object obj) throws IOException {
if (obj == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginArray();
int length = Array.getLength(obj);
for (int i = 0; i < length; i++) {
this.componentTypeAdapter.write(jsonWriter, Array.get(obj, i));
}
jsonWriter.endArray();
}
}

View File

@@ -0,0 +1,75 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.C$Gson$Types;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.ObjectConstructor;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Iterator;
/* loaded from: classes.dex */
public final class CollectionTypeAdapterFactory implements TypeAdapterFactory {
private final ConstructorConstructor constructorConstructor;
private static final class Adapter<E> extends TypeAdapter<Collection<E>> {
private final ObjectConstructor<? extends Collection<E>> constructor;
private final TypeAdapter<E> elementTypeAdapter;
public Adapter(Gson gson, Type type, TypeAdapter<E> typeAdapter, ObjectConstructor<? extends Collection<E>> objectConstructor) {
this.elementTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, type);
this.constructor = objectConstructor;
}
@Override // com.google.gson.TypeAdapter
public Collection<E> read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
Collection<E> construct = this.constructor.construct();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
construct.add(this.elementTypeAdapter.read(jsonReader));
}
jsonReader.endArray();
return construct;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Collection<E> collection) throws IOException {
if (collection == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginArray();
Iterator<E> it = collection.iterator();
while (it.hasNext()) {
this.elementTypeAdapter.write(jsonWriter, it.next());
}
jsonWriter.endArray();
}
}
public CollectionTypeAdapterFactory(ConstructorConstructor constructorConstructor) {
this.constructorConstructor = constructorConstructor;
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
Class<? super T> rawType = typeToken.getRawType();
if (!Collection.class.isAssignableFrom(rawType)) {
return null;
}
Type collectionElementType = C$Gson$Types.getCollectionElementType(type, rawType);
return new Adapter(gson, collectionElementType, gson.getAdapter(TypeToken.get(collectionElementType)), this.constructorConstructor.get(typeToken));
}
}

View File

@@ -0,0 +1,66 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Date;
import java.util.Locale;
/* loaded from: classes.dex */
public final class DateTypeAdapter extends TypeAdapter<Date> {
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.DateTypeAdapter.1
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() == Date.class) {
return new DateTypeAdapter();
}
return null;
}
};
private final DateFormat enUsFormat = DateFormat.getDateTimeInstance(2, 2, Locale.US);
private final DateFormat localFormat = DateFormat.getDateTimeInstance(2, 2);
private synchronized Date deserializeToDate(String str) {
try {
try {
try {
} catch (ParseException unused) {
return this.enUsFormat.parse(str);
}
} catch (ParseException unused2) {
return ISO8601Utils.parse(str, new ParsePosition(0));
}
} catch (ParseException e) {
throw new JsonSyntaxException(str, e);
}
return this.localFormat.parse(str);
}
@Override // com.google.gson.TypeAdapter
public Date read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return deserializeToDate(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public synchronized void write(JsonWriter jsonWriter, Date date) throws IOException {
if (date == null) {
jsonWriter.nullValue();
} else {
jsonWriter.value(this.enUsFormat.format(date));
}
}
}

View File

@@ -0,0 +1,45 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonSerializer;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.reflect.TypeToken;
/* loaded from: classes.dex */
public final class JsonAdapterAnnotationTypeAdapterFactory implements TypeAdapterFactory {
private final ConstructorConstructor constructorConstructor;
public JsonAdapterAnnotationTypeAdapterFactory(ConstructorConstructor constructorConstructor) {
this.constructorConstructor = constructorConstructor;
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
JsonAdapter jsonAdapter = (JsonAdapter) typeToken.getRawType().getAnnotation(JsonAdapter.class);
if (jsonAdapter == null) {
return null;
}
return (TypeAdapter<T>) getTypeAdapter(this.constructorConstructor, gson, typeToken, jsonAdapter);
}
TypeAdapter<?> getTypeAdapter(ConstructorConstructor constructorConstructor, Gson gson, TypeToken<?> typeToken, JsonAdapter jsonAdapter) {
TypeAdapter<?> treeTypeAdapter;
Object construct = constructorConstructor.get(TypeToken.get((Class) jsonAdapter.value())).construct();
if (construct instanceof TypeAdapter) {
treeTypeAdapter = (TypeAdapter) construct;
} else if (construct instanceof TypeAdapterFactory) {
treeTypeAdapter = ((TypeAdapterFactory) construct).create(gson, typeToken);
} else {
boolean z = construct instanceof JsonSerializer;
if (!z && !(construct instanceof JsonDeserializer)) {
throw new IllegalArgumentException("Invalid attempt to bind an instance of " + construct.getClass().getName() + " as a @JsonAdapter for " + typeToken.toString() + ". @JsonAdapter value must be a TypeAdapter, TypeAdapterFactory, JsonSerializer or JsonDeserializer.");
}
treeTypeAdapter = new TreeTypeAdapter<>(z ? (JsonSerializer) construct : null, construct instanceof JsonDeserializer ? (JsonDeserializer) construct : null, gson, typeToken, null);
}
return (treeTypeAdapter == null || !jsonAdapter.nullSafe()) ? treeTypeAdapter : treeTypeAdapter.nullSafe();
}
}

View File

@@ -0,0 +1,349 @@
package com.google.gson.internal.bind;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import java.io.IOException;
import java.io.Reader;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes.dex */
public final class JsonTreeReader extends JsonReader {
private int[] pathIndices;
private String[] pathNames;
private Object[] stack;
private int stackSize;
private static final Reader UNREADABLE_READER = new Reader() { // from class: com.google.gson.internal.bind.JsonTreeReader.1
@Override // java.io.Reader, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
throw new AssertionError();
}
@Override // java.io.Reader
public int read(char[] cArr, int i, int i2) throws IOException {
throw new AssertionError();
}
};
private static final Object SENTINEL_CLOSED = new Object();
public JsonTreeReader(JsonElement jsonElement) {
super(UNREADABLE_READER);
this.stack = new Object[32];
this.stackSize = 0;
this.pathNames = new String[32];
this.pathIndices = new int[32];
push(jsonElement);
}
private void expect(JsonToken jsonToken) throws IOException {
if (peek() == jsonToken) {
return;
}
throw new IllegalStateException("Expected " + jsonToken + " but was " + peek() + locationString());
}
private String locationString() {
return " at path " + getPath();
}
private Object peekStack() {
return this.stack[this.stackSize - 1];
}
private Object popStack() {
Object[] objArr = this.stack;
int i = this.stackSize - 1;
this.stackSize = i;
Object obj = objArr[i];
objArr[this.stackSize] = null;
return obj;
}
private void push(Object obj) {
int i = this.stackSize;
Object[] objArr = this.stack;
if (i == objArr.length) {
Object[] objArr2 = new Object[i * 2];
int[] iArr = new int[i * 2];
String[] strArr = new String[i * 2];
System.arraycopy(objArr, 0, objArr2, 0, i);
System.arraycopy(this.pathIndices, 0, iArr, 0, this.stackSize);
System.arraycopy(this.pathNames, 0, strArr, 0, this.stackSize);
this.stack = objArr2;
this.pathIndices = iArr;
this.pathNames = strArr;
}
Object[] objArr3 = this.stack;
int i2 = this.stackSize;
this.stackSize = i2 + 1;
objArr3[i2] = obj;
}
@Override // com.google.gson.stream.JsonReader
public void beginArray() throws IOException {
expect(JsonToken.BEGIN_ARRAY);
push(((JsonArray) peekStack()).iterator());
this.pathIndices[this.stackSize - 1] = 0;
}
@Override // com.google.gson.stream.JsonReader
public void beginObject() throws IOException {
expect(JsonToken.BEGIN_OBJECT);
push(((JsonObject) peekStack()).entrySet().iterator());
}
@Override // com.google.gson.stream.JsonReader, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.stack = new Object[]{SENTINEL_CLOSED};
this.stackSize = 1;
}
@Override // com.google.gson.stream.JsonReader
public void endArray() throws IOException {
expect(JsonToken.END_ARRAY);
popStack();
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
}
@Override // com.google.gson.stream.JsonReader
public void endObject() throws IOException {
expect(JsonToken.END_OBJECT);
popStack();
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
}
@Override // com.google.gson.stream.JsonReader
public String getPath() {
StringBuilder sb = new StringBuilder();
sb.append('$');
int i = 0;
while (i < this.stackSize) {
Object[] objArr = this.stack;
if (objArr[i] instanceof JsonArray) {
i++;
if (objArr[i] instanceof Iterator) {
sb.append('[');
sb.append(this.pathIndices[i]);
sb.append(']');
}
} else if (objArr[i] instanceof JsonObject) {
i++;
if (objArr[i] instanceof Iterator) {
sb.append('.');
String[] strArr = this.pathNames;
if (strArr[i] != null) {
sb.append(strArr[i]);
}
}
}
i++;
}
return sb.toString();
}
@Override // com.google.gson.stream.JsonReader
public boolean hasNext() throws IOException {
JsonToken peek = peek();
return (peek == JsonToken.END_OBJECT || peek == JsonToken.END_ARRAY) ? false : true;
}
@Override // com.google.gson.stream.JsonReader
public boolean nextBoolean() throws IOException {
expect(JsonToken.BOOLEAN);
boolean asBoolean = ((JsonPrimitive) popStack()).getAsBoolean();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
return asBoolean;
}
@Override // com.google.gson.stream.JsonReader
public double nextDouble() throws IOException {
JsonToken peek = peek();
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
}
double asDouble = ((JsonPrimitive) peekStack()).getAsDouble();
if (!isLenient() && (Double.isNaN(asDouble) || Double.isInfinite(asDouble))) {
throw new NumberFormatException("JSON forbids NaN and infinities: " + asDouble);
}
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
return asDouble;
}
@Override // com.google.gson.stream.JsonReader
public int nextInt() throws IOException {
JsonToken peek = peek();
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
}
int asInt = ((JsonPrimitive) peekStack()).getAsInt();
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
return asInt;
}
@Override // com.google.gson.stream.JsonReader
public long nextLong() throws IOException {
JsonToken peek = peek();
if (peek != JsonToken.NUMBER && peek != JsonToken.STRING) {
throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + peek + locationString());
}
long asLong = ((JsonPrimitive) peekStack()).getAsLong();
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
return asLong;
}
@Override // com.google.gson.stream.JsonReader
public String nextName() throws IOException {
expect(JsonToken.NAME);
Map.Entry entry = (Map.Entry) ((Iterator) peekStack()).next();
String str = (String) entry.getKey();
this.pathNames[this.stackSize - 1] = str;
push(entry.getValue());
return str;
}
@Override // com.google.gson.stream.JsonReader
public void nextNull() throws IOException {
expect(JsonToken.NULL);
popStack();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
}
@Override // com.google.gson.stream.JsonReader
public String nextString() throws IOException {
JsonToken peek = peek();
if (peek == JsonToken.STRING || peek == JsonToken.NUMBER) {
String asString = ((JsonPrimitive) popStack()).getAsString();
int i = this.stackSize;
if (i > 0) {
int[] iArr = this.pathIndices;
int i2 = i - 1;
iArr[i2] = iArr[i2] + 1;
}
return asString;
}
throw new IllegalStateException("Expected " + JsonToken.STRING + " but was " + peek + locationString());
}
@Override // com.google.gson.stream.JsonReader
public JsonToken peek() throws IOException {
if (this.stackSize == 0) {
return JsonToken.END_DOCUMENT;
}
Object peekStack = peekStack();
if (peekStack instanceof Iterator) {
boolean z = this.stack[this.stackSize - 2] instanceof JsonObject;
Iterator it = (Iterator) peekStack;
if (!it.hasNext()) {
return z ? JsonToken.END_OBJECT : JsonToken.END_ARRAY;
}
if (z) {
return JsonToken.NAME;
}
push(it.next());
return peek();
}
if (peekStack instanceof JsonObject) {
return JsonToken.BEGIN_OBJECT;
}
if (peekStack instanceof JsonArray) {
return JsonToken.BEGIN_ARRAY;
}
if (!(peekStack instanceof JsonPrimitive)) {
if (peekStack instanceof JsonNull) {
return JsonToken.NULL;
}
if (peekStack == SENTINEL_CLOSED) {
throw new IllegalStateException("JsonReader is closed");
}
throw new AssertionError();
}
JsonPrimitive jsonPrimitive = (JsonPrimitive) peekStack;
if (jsonPrimitive.isString()) {
return JsonToken.STRING;
}
if (jsonPrimitive.isBoolean()) {
return JsonToken.BOOLEAN;
}
if (jsonPrimitive.isNumber()) {
return JsonToken.NUMBER;
}
throw new AssertionError();
}
public void promoteNameToValue() throws IOException {
expect(JsonToken.NAME);
Map.Entry entry = (Map.Entry) ((Iterator) peekStack()).next();
push(entry.getValue());
push(new JsonPrimitive((String) entry.getKey()));
}
@Override // com.google.gson.stream.JsonReader
public void skipValue() throws IOException {
if (peek() == JsonToken.NAME) {
nextName();
this.pathNames[this.stackSize - 2] = "null";
} else {
popStack();
int i = this.stackSize;
if (i > 0) {
this.pathNames[i - 1] = "null";
}
}
int i2 = this.stackSize;
if (i2 > 0) {
int[] iArr = this.pathIndices;
int i3 = i2 - 1;
iArr[i3] = iArr[i3] + 1;
}
}
@Override // com.google.gson.stream.JsonReader
public String toString() {
return JsonTreeReader.class.getSimpleName();
}
}

View File

@@ -0,0 +1,196 @@
package com.google.gson.internal.bind;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public final class JsonTreeWriter extends JsonWriter {
private String pendingName;
private JsonElement product;
private final List<JsonElement> stack;
private static final Writer UNWRITABLE_WRITER = new Writer() { // from class: com.google.gson.internal.bind.JsonTreeWriter.1
@Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
throw new AssertionError();
}
@Override // java.io.Writer, java.io.Flushable
public void flush() throws IOException {
throw new AssertionError();
}
@Override // java.io.Writer
public void write(char[] cArr, int i, int i2) {
throw new AssertionError();
}
};
private static final JsonPrimitive SENTINEL_CLOSED = new JsonPrimitive("closed");
public JsonTreeWriter() {
super(UNWRITABLE_WRITER);
this.stack = new ArrayList();
this.product = JsonNull.INSTANCE;
}
private JsonElement peek() {
return this.stack.get(r0.size() - 1);
}
private void put(JsonElement jsonElement) {
if (this.pendingName != null) {
if (!jsonElement.isJsonNull() || getSerializeNulls()) {
((JsonObject) peek()).add(this.pendingName, jsonElement);
}
this.pendingName = null;
return;
}
if (this.stack.isEmpty()) {
this.product = jsonElement;
return;
}
JsonElement peek = peek();
if (!(peek instanceof JsonArray)) {
throw new IllegalStateException();
}
((JsonArray) peek).add(jsonElement);
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter beginArray() throws IOException {
JsonArray jsonArray = new JsonArray();
put(jsonArray);
this.stack.add(jsonArray);
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter beginObject() throws IOException {
JsonObject jsonObject = new JsonObject();
put(jsonObject);
this.stack.add(jsonObject);
return this;
}
@Override // com.google.gson.stream.JsonWriter, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
if (!this.stack.isEmpty()) {
throw new IOException("Incomplete document");
}
this.stack.add(SENTINEL_CLOSED);
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter endArray() throws IOException {
if (this.stack.isEmpty() || this.pendingName != null) {
throw new IllegalStateException();
}
if (!(peek() instanceof JsonArray)) {
throw new IllegalStateException();
}
this.stack.remove(r0.size() - 1);
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter endObject() throws IOException {
if (this.stack.isEmpty() || this.pendingName != null) {
throw new IllegalStateException();
}
if (!(peek() instanceof JsonObject)) {
throw new IllegalStateException();
}
this.stack.remove(r0.size() - 1);
return this;
}
@Override // com.google.gson.stream.JsonWriter, java.io.Flushable
public void flush() throws IOException {
}
public JsonElement get() {
if (this.stack.isEmpty()) {
return this.product;
}
throw new IllegalStateException("Expected one JSON element but was " + this.stack);
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter name(String str) throws IOException {
if (this.stack.isEmpty() || this.pendingName != null) {
throw new IllegalStateException();
}
if (!(peek() instanceof JsonObject)) {
throw new IllegalStateException();
}
this.pendingName = str;
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter nullValue() throws IOException {
put(JsonNull.INSTANCE);
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(String str) throws IOException {
if (str == null) {
return nullValue();
}
put(new JsonPrimitive(str));
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(boolean z) throws IOException {
put(new JsonPrimitive(Boolean.valueOf(z)));
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(Boolean bool) throws IOException {
if (bool == null) {
return nullValue();
}
put(new JsonPrimitive(bool));
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(double d) throws IOException {
if (!isLenient() && (Double.isNaN(d) || Double.isInfinite(d))) {
throw new IllegalArgumentException("JSON forbids NaN and infinities: " + d);
}
put(new JsonPrimitive((Number) Double.valueOf(d)));
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(long j) throws IOException {
put(new JsonPrimitive((Number) Long.valueOf(j)));
return this;
}
@Override // com.google.gson.stream.JsonWriter
public JsonWriter value(Number number) throws IOException {
if (number == null) {
return nullValue();
}
if (!isLenient()) {
double doubleValue = number.doubleValue();
if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) {
throw new IllegalArgumentException("JSON forbids NaN and infinities: " + number);
}
}
put(new JsonPrimitive(number));
return this;
}
}

View File

@@ -0,0 +1,159 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.C$Gson$Types;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.JsonReaderInternalAccess;
import com.google.gson.internal.ObjectConstructor;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Map;
/* loaded from: classes.dex */
public final class MapTypeAdapterFactory implements TypeAdapterFactory {
final boolean complexMapKeySerialization;
private final ConstructorConstructor constructorConstructor;
private final class Adapter<K, V> extends TypeAdapter<Map<K, V>> {
private final ObjectConstructor<? extends Map<K, V>> constructor;
private final TypeAdapter<K> keyTypeAdapter;
private final TypeAdapter<V> valueTypeAdapter;
public Adapter(Gson gson, Type type, TypeAdapter<K> typeAdapter, Type type2, TypeAdapter<V> typeAdapter2, ObjectConstructor<? extends Map<K, V>> objectConstructor) {
this.keyTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter, type);
this.valueTypeAdapter = new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter2, type2);
this.constructor = objectConstructor;
}
private String keyToString(JsonElement jsonElement) {
if (!jsonElement.isJsonPrimitive()) {
if (jsonElement.isJsonNull()) {
return "null";
}
throw new AssertionError();
}
JsonPrimitive asJsonPrimitive = jsonElement.getAsJsonPrimitive();
if (asJsonPrimitive.isNumber()) {
return String.valueOf(asJsonPrimitive.getAsNumber());
}
if (asJsonPrimitive.isBoolean()) {
return Boolean.toString(asJsonPrimitive.getAsBoolean());
}
if (asJsonPrimitive.isString()) {
return asJsonPrimitive.getAsString();
}
throw new AssertionError();
}
@Override // com.google.gson.TypeAdapter
public Map<K, V> read(JsonReader jsonReader) throws IOException {
JsonToken peek = jsonReader.peek();
if (peek == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
Map<K, V> construct = this.constructor.construct();
if (peek == JsonToken.BEGIN_ARRAY) {
jsonReader.beginArray();
while (jsonReader.hasNext()) {
jsonReader.beginArray();
K read = this.keyTypeAdapter.read(jsonReader);
if (construct.put(read, this.valueTypeAdapter.read(jsonReader)) != null) {
throw new JsonSyntaxException("duplicate key: " + read);
}
jsonReader.endArray();
}
jsonReader.endArray();
} else {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
JsonReaderInternalAccess.INSTANCE.promoteNameToValue(jsonReader);
K read2 = this.keyTypeAdapter.read(jsonReader);
if (construct.put(read2, this.valueTypeAdapter.read(jsonReader)) != null) {
throw new JsonSyntaxException("duplicate key: " + read2);
}
}
jsonReader.endObject();
}
return construct;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Map<K, V> map) throws IOException {
if (map == null) {
jsonWriter.nullValue();
return;
}
if (!MapTypeAdapterFactory.this.complexMapKeySerialization) {
jsonWriter.beginObject();
for (Map.Entry<K, V> entry : map.entrySet()) {
jsonWriter.name(String.valueOf(entry.getKey()));
this.valueTypeAdapter.write(jsonWriter, entry.getValue());
}
jsonWriter.endObject();
return;
}
ArrayList arrayList = new ArrayList(map.size());
ArrayList arrayList2 = new ArrayList(map.size());
int i = 0;
boolean z = false;
for (Map.Entry<K, V> entry2 : map.entrySet()) {
JsonElement jsonTree = this.keyTypeAdapter.toJsonTree(entry2.getKey());
arrayList.add(jsonTree);
arrayList2.add(entry2.getValue());
z |= jsonTree.isJsonArray() || jsonTree.isJsonObject();
}
if (!z) {
jsonWriter.beginObject();
int size = arrayList.size();
while (i < size) {
jsonWriter.name(keyToString((JsonElement) arrayList.get(i)));
this.valueTypeAdapter.write(jsonWriter, arrayList2.get(i));
i++;
}
jsonWriter.endObject();
return;
}
jsonWriter.beginArray();
int size2 = arrayList.size();
while (i < size2) {
jsonWriter.beginArray();
Streams.write((JsonElement) arrayList.get(i), jsonWriter);
this.valueTypeAdapter.write(jsonWriter, arrayList2.get(i));
jsonWriter.endArray();
i++;
}
jsonWriter.endArray();
}
}
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor, boolean z) {
this.constructorConstructor = constructorConstructor;
this.complexMapKeySerialization = z;
}
private TypeAdapter<?> getKeyAdapter(Gson gson, Type type) {
return (type == Boolean.TYPE || type == Boolean.class) ? TypeAdapters.BOOLEAN_AS_STRING : gson.getAdapter(TypeToken.get(type));
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
if (!Map.class.isAssignableFrom(typeToken.getRawType())) {
return null;
}
Type[] mapKeyAndValueTypes = C$Gson$Types.getMapKeyAndValueTypes(type, C$Gson$Types.getRawType(type));
return new Adapter(gson, mapKeyAndValueTypes[0], getKeyAdapter(gson, mapKeyAndValueTypes[0]), mapKeyAndValueTypes[1], gson.getAdapter(TypeToken.get(mapKeyAndValueTypes[1])), this.constructorConstructor.get(typeToken));
}
}

View File

@@ -0,0 +1,110 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
/* loaded from: classes.dex */
public final class ObjectTypeAdapter extends TypeAdapter<Object> {
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.ObjectTypeAdapter.1
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() == Object.class) {
return new ObjectTypeAdapter(gson);
}
return null;
}
};
private final Gson gson;
/* renamed from: com.google.gson.internal.bind.ObjectTypeAdapter$2, reason: invalid class name */
static /* synthetic */ class AnonymousClass2 {
static final /* synthetic */ int[] $SwitchMap$com$google$gson$stream$JsonToken = new int[JsonToken.values().length];
static {
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_ARRAY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_OBJECT.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.STRING.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NUMBER.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BOOLEAN.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NULL.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
}
}
ObjectTypeAdapter(Gson gson) {
this.gson = gson;
}
@Override // com.google.gson.TypeAdapter
public Object read(JsonReader jsonReader) throws IOException {
switch (AnonymousClass2.$SwitchMap$com$google$gson$stream$JsonToken[jsonReader.peek().ordinal()]) {
case 1:
ArrayList arrayList = new ArrayList();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
arrayList.add(read(jsonReader));
}
jsonReader.endArray();
return arrayList;
case 2:
LinkedTreeMap linkedTreeMap = new LinkedTreeMap();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
linkedTreeMap.put(jsonReader.nextName(), read(jsonReader));
}
jsonReader.endObject();
return linkedTreeMap;
case 3:
return jsonReader.nextString();
case 4:
return Double.valueOf(jsonReader.nextDouble());
case 5:
return Boolean.valueOf(jsonReader.nextBoolean());
case 6:
jsonReader.nextNull();
return null;
default:
throw new IllegalStateException();
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Object obj) throws IOException {
if (obj == null) {
jsonWriter.nullValue();
return;
}
TypeAdapter adapter = this.gson.getAdapter(obj.getClass());
if (!(adapter instanceof ObjectTypeAdapter)) {
adapter.write(jsonWriter, obj);
} else {
jsonWriter.beginObject();
jsonWriter.endObject();
}
}
}

View File

@@ -0,0 +1,233 @@
package com.google.gson.internal.bind;
import com.google.gson.FieldNamingStrategy;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.internal.C$Gson$Types;
import com.google.gson.internal.ConstructorConstructor;
import com.google.gson.internal.Excluder;
import com.google.gson.internal.ObjectConstructor;
import com.google.gson.internal.Primitives;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
private final ConstructorConstructor constructorConstructor;
private final Excluder excluder;
private final FieldNamingStrategy fieldNamingPolicy;
private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory;
public static final class Adapter<T> extends TypeAdapter<T> {
private final Map<String, BoundField> boundFields;
private final ObjectConstructor<T> constructor;
Adapter(ObjectConstructor<T> objectConstructor, Map<String, BoundField> map) {
this.constructor = objectConstructor;
this.boundFields = map;
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
T construct = this.constructor.construct();
try {
jsonReader.beginObject();
while (jsonReader.hasNext()) {
BoundField boundField = this.boundFields.get(jsonReader.nextName());
if (boundField != null && boundField.deserialized) {
boundField.read(jsonReader, construct);
}
jsonReader.skipValue();
}
jsonReader.endObject();
return construct;
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (IllegalStateException e2) {
throw new JsonSyntaxException(e2);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
if (t == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginObject();
try {
for (BoundField boundField : this.boundFields.values()) {
if (boundField.writeField(t)) {
jsonWriter.name(boundField.name);
boundField.write(jsonWriter, t);
}
}
jsonWriter.endObject();
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
}
}
static abstract class BoundField {
final boolean deserialized;
final String name;
final boolean serialized;
protected BoundField(String str, boolean z, boolean z2) {
this.name = str;
this.serialized = z;
this.deserialized = z2;
}
abstract void read(JsonReader jsonReader, Object obj) throws IOException, IllegalAccessException;
abstract void write(JsonWriter jsonWriter, Object obj) throws IOException, IllegalAccessException;
abstract boolean writeField(Object obj) throws IOException, IllegalAccessException;
}
public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingStrategy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterAnnotationTypeAdapterFactory) {
this.constructorConstructor = constructorConstructor;
this.fieldNamingPolicy = fieldNamingStrategy;
this.excluder = excluder;
this.jsonAdapterFactory = jsonAdapterAnnotationTypeAdapterFactory;
}
private BoundField createBoundField(final Gson gson, final Field field, String str, final TypeToken<?> typeToken, boolean z, boolean z2) {
final boolean isPrimitive = Primitives.isPrimitive(typeToken.getRawType());
JsonAdapter jsonAdapter = (JsonAdapter) field.getAnnotation(JsonAdapter.class);
TypeAdapter<?> typeAdapter = jsonAdapter != null ? this.jsonAdapterFactory.getTypeAdapter(this.constructorConstructor, gson, typeToken, jsonAdapter) : null;
final boolean z3 = typeAdapter != null;
if (typeAdapter == null) {
typeAdapter = gson.getAdapter(typeToken);
}
final TypeAdapter<?> typeAdapter2 = typeAdapter;
return new BoundField(str, z, z2) { // from class: com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.1
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
void read(JsonReader jsonReader, Object obj) throws IOException, IllegalAccessException {
Object read = typeAdapter2.read(jsonReader);
if (read == null && isPrimitive) {
return;
}
field.set(obj, read);
}
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
void write(JsonWriter jsonWriter, Object obj) throws IOException, IllegalAccessException {
(z3 ? typeAdapter2 : new TypeAdapterRuntimeTypeWrapper(gson, typeAdapter2, typeToken.getType())).write(jsonWriter, field.get(obj));
}
@Override // com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.BoundField
public boolean writeField(Object obj) throws IOException, IllegalAccessException {
return this.serialized && field.get(obj) != obj;
}
};
}
private Map<String, BoundField> getBoundFields(Gson gson, TypeToken<?> typeToken, Class<?> cls) {
LinkedHashMap linkedHashMap = new LinkedHashMap();
if (cls.isInterface()) {
return linkedHashMap;
}
Type type = typeToken.getType();
TypeToken<?> typeToken2 = typeToken;
Class<?> cls2 = cls;
while (cls2 != Object.class) {
Field[] declaredFields = cls2.getDeclaredFields();
int length = declaredFields.length;
boolean z = false;
int i = 0;
while (i < length) {
Field field = declaredFields[i];
boolean excludeField = excludeField(field, true);
boolean excludeField2 = excludeField(field, z);
if (excludeField || excludeField2) {
field.setAccessible(true);
Type resolve = C$Gson$Types.resolve(typeToken2.getType(), cls2, field.getGenericType());
List<String> fieldNames = getFieldNames(field);
int size = fieldNames.size();
BoundField boundField = null;
int i2 = 0;
while (i2 < size) {
String str = fieldNames.get(i2);
boolean z2 = i2 != 0 ? false : excludeField;
BoundField boundField2 = boundField;
int i3 = i2;
int i4 = size;
List<String> list = fieldNames;
Field field2 = field;
boundField = boundField2 == null ? (BoundField) linkedHashMap.put(str, createBoundField(gson, field, str, TypeToken.get(resolve), z2, excludeField2)) : boundField2;
i2 = i3 + 1;
excludeField = z2;
fieldNames = list;
size = i4;
field = field2;
}
BoundField boundField3 = boundField;
if (boundField3 != null) {
throw new IllegalArgumentException(type + " declares multiple JSON fields named " + boundField3.name);
}
}
i++;
z = false;
}
typeToken2 = TypeToken.get(C$Gson$Types.resolve(typeToken2.getType(), cls2, cls2.getGenericSuperclass()));
cls2 = typeToken2.getRawType();
}
return linkedHashMap;
}
private List<String> getFieldNames(Field field) {
SerializedName serializedName = (SerializedName) field.getAnnotation(SerializedName.class);
if (serializedName == null) {
return Collections.singletonList(this.fieldNamingPolicy.translateName(field));
}
String value = serializedName.value();
String[] alternate = serializedName.alternate();
if (alternate.length == 0) {
return Collections.singletonList(value);
}
ArrayList arrayList = new ArrayList(alternate.length + 1);
arrayList.add(value);
for (String str : alternate) {
arrayList.add(str);
}
return arrayList;
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (Object.class.isAssignableFrom(rawType)) {
return new Adapter(this.constructorConstructor.get(typeToken), getBoundFields(gson, typeToken, rawType));
}
return null;
}
public boolean excludeField(Field field, boolean z) {
return excludeField(field, z, this.excluder);
}
static boolean excludeField(Field field, boolean z, Excluder excluder) {
return (excluder.excludeClass(field.getType(), z) || excluder.excludeField(field, z)) ? false : true;
}
}

View File

@@ -0,0 +1,47 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.sql.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/* loaded from: classes.dex */
public final class SqlDateTypeAdapter extends TypeAdapter<Date> {
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.SqlDateTypeAdapter.1
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() == Date.class) {
return new SqlDateTypeAdapter();
}
return null;
}
};
private final DateFormat format = new SimpleDateFormat("MMM d, yyyy");
@Override // com.google.gson.TypeAdapter
public synchronized Date read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return new Date(this.format.parse(jsonReader.nextString()).getTime());
} catch (ParseException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public synchronized void write(JsonWriter jsonWriter, Date date) throws IOException {
jsonWriter.value(date == null ? null : this.format.format((java.util.Date) date));
}
}

View File

@@ -0,0 +1,48 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.sql.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/* loaded from: classes.dex */
public final class TimeTypeAdapter extends TypeAdapter<Time> {
public static final TypeAdapterFactory FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TimeTypeAdapter.1
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() == Time.class) {
return new TimeTypeAdapter();
}
return null;
}
};
private final DateFormat format = new SimpleDateFormat("hh:mm:ss a");
@Override // com.google.gson.TypeAdapter
public synchronized Time read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return new Time(this.format.parse(jsonReader.nextString()).getTime());
} catch (ParseException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public synchronized void write(JsonWriter jsonWriter, Time time) throws IOException {
jsonWriter.value(time == null ? null : this.format.format((Date) time));
}
}

View File

@@ -0,0 +1,129 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.internal.C$Gson$Preconditions;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
/* loaded from: classes.dex */
public final class TreeTypeAdapter<T> extends TypeAdapter<T> {
private final TreeTypeAdapter<T>.GsonContextImpl context = new GsonContextImpl();
private TypeAdapter<T> delegate;
private final JsonDeserializer<T> deserializer;
final Gson gson;
private final JsonSerializer<T> serializer;
private final TypeAdapterFactory skipPast;
private final TypeToken<T> typeToken;
private final class GsonContextImpl implements JsonSerializationContext, JsonDeserializationContext {
private GsonContextImpl() {
}
@Override // com.google.gson.JsonDeserializationContext
public <R> R deserialize(JsonElement jsonElement, Type type) throws JsonParseException {
return (R) TreeTypeAdapter.this.gson.fromJson(jsonElement, type);
}
@Override // com.google.gson.JsonSerializationContext
public JsonElement serialize(Object obj) {
return TreeTypeAdapter.this.gson.toJsonTree(obj);
}
@Override // com.google.gson.JsonSerializationContext
public JsonElement serialize(Object obj, Type type) {
return TreeTypeAdapter.this.gson.toJsonTree(obj, type);
}
}
private static final class SingleTypeFactory implements TypeAdapterFactory {
private final JsonDeserializer<?> deserializer;
private final TypeToken<?> exactType;
private final Class<?> hierarchyType;
private final boolean matchRawType;
private final JsonSerializer<?> serializer;
SingleTypeFactory(Object obj, TypeToken<?> typeToken, boolean z, Class<?> cls) {
this.serializer = obj instanceof JsonSerializer ? (JsonSerializer) obj : null;
this.deserializer = obj instanceof JsonDeserializer ? (JsonDeserializer) obj : null;
C$Gson$Preconditions.checkArgument((this.serializer == null && this.deserializer == null) ? false : true);
this.exactType = typeToken;
this.matchRawType = z;
this.hierarchyType = cls;
}
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
TypeToken<?> typeToken2 = this.exactType;
if (typeToken2 != null ? typeToken2.equals(typeToken) || (this.matchRawType && this.exactType.getType() == typeToken.getRawType()) : this.hierarchyType.isAssignableFrom(typeToken.getRawType())) {
return new TreeTypeAdapter(this.serializer, this.deserializer, gson, typeToken, this);
}
return null;
}
}
public TreeTypeAdapter(JsonSerializer<T> jsonSerializer, JsonDeserializer<T> jsonDeserializer, Gson gson, TypeToken<T> typeToken, TypeAdapterFactory typeAdapterFactory) {
this.serializer = jsonSerializer;
this.deserializer = jsonDeserializer;
this.gson = gson;
this.typeToken = typeToken;
this.skipPast = typeAdapterFactory;
}
private TypeAdapter<T> delegate() {
TypeAdapter<T> typeAdapter = this.delegate;
if (typeAdapter != null) {
return typeAdapter;
}
TypeAdapter<T> delegateAdapter = this.gson.getDelegateAdapter(this.skipPast, this.typeToken);
this.delegate = delegateAdapter;
return delegateAdapter;
}
public static TypeAdapterFactory newFactory(TypeToken<?> typeToken, Object obj) {
return new SingleTypeFactory(obj, typeToken, false, null);
}
public static TypeAdapterFactory newFactoryWithMatchRawType(TypeToken<?> typeToken, Object obj) {
return new SingleTypeFactory(obj, typeToken, typeToken.getType() == typeToken.getRawType(), null);
}
public static TypeAdapterFactory newTypeHierarchyFactory(Class<?> cls, Object obj) {
return new SingleTypeFactory(obj, null, false, cls);
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
if (this.deserializer == null) {
return delegate().read(jsonReader);
}
JsonElement parse = Streams.parse(jsonReader);
if (parse.isJsonNull()) {
return null;
}
return this.deserializer.deserialize(parse, this.typeToken.getType(), this.context);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
JsonSerializer<T> jsonSerializer = this.serializer;
if (jsonSerializer == null) {
delegate().write(jsonWriter, t);
} else if (t == null) {
jsonWriter.nullValue();
} else {
Streams.write(jsonSerializer.serialize(t, this.typeToken.getType(), this.context), jsonWriter);
}
}
}

View File

@@ -0,0 +1,49 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
/* loaded from: classes.dex */
final class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
private final Gson context;
private final TypeAdapter<T> delegate;
private final Type type;
TypeAdapterRuntimeTypeWrapper(Gson gson, TypeAdapter<T> typeAdapter, Type type) {
this.context = gson;
this.delegate = typeAdapter;
this.type = type;
}
private Type getRuntimeTypeIfMoreSpecific(Type type, Object obj) {
return obj != null ? (type == Object.class || (type instanceof TypeVariable) || (type instanceof Class)) ? obj.getClass() : type : type;
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
return this.delegate.read(jsonReader);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
TypeAdapter<T> typeAdapter = this.delegate;
Type runtimeTypeIfMoreSpecific = getRuntimeTypeIfMoreSpecific(this.type, t);
if (runtimeTypeIfMoreSpecific != this.type) {
typeAdapter = this.context.getAdapter(TypeToken.get(runtimeTypeIfMoreSpecific));
if (typeAdapter instanceof ReflectiveTypeAdapterFactory.Adapter) {
TypeAdapter<T> typeAdapter2 = this.delegate;
if (!(typeAdapter2 instanceof ReflectiveTypeAdapterFactory.Adapter)) {
typeAdapter = typeAdapter2;
}
}
}
typeAdapter.write(jsonWriter, t);
}
}

View File

@@ -0,0 +1,961 @@
package com.google.gson.internal.bind;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.SerializedName;
import com.google.gson.internal.LazilyParsedNumber;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Currency;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
/* loaded from: classes.dex */
public final class TypeAdapters {
public static final TypeAdapter<Class> CLASS = new TypeAdapter<Class>() { // from class: com.google.gson.internal.bind.TypeAdapters.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Class read(JsonReader jsonReader) throws IOException {
throw new UnsupportedOperationException("Attempted to deserialize a java.lang.Class. Forgot to register a type adapter?");
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Class cls) throws IOException {
throw new UnsupportedOperationException("Attempted to serialize java.lang.Class: " + cls.getName() + ". Forgot to register a type adapter?");
}
}.nullSafe();
public static final TypeAdapterFactory CLASS_FACTORY = newFactory(Class.class, CLASS);
public static final TypeAdapter<BitSet> BIT_SET = new TypeAdapter<BitSet>() { // from class: com.google.gson.internal.bind.TypeAdapters.2
/* JADX WARN: Code restructure failed: missing block: B:13:0x002b, code lost:
if (java.lang.Integer.parseInt(r1) != 0) goto L23;
*/
/* JADX WARN: Code restructure failed: missing block: B:14:0x002e, code lost:
r5 = false;
*/
/* JADX WARN: Code restructure failed: missing block: B:29:0x0067, code lost:
if (r8.nextInt() != 0) goto L23;
*/
@Override // com.google.gson.TypeAdapter
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public java.util.BitSet read(com.google.gson.stream.JsonReader r8) throws java.io.IOException {
/*
r7 = this;
java.util.BitSet r0 = new java.util.BitSet
r0.<init>()
r8.beginArray()
com.google.gson.stream.JsonToken r1 = r8.peek()
r2 = 0
r3 = 0
Le:
com.google.gson.stream.JsonToken r4 = com.google.gson.stream.JsonToken.END_ARRAY
if (r1 == r4) goto L75
int[] r4 = com.google.gson.internal.bind.TypeAdapters.AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken
int r5 = r1.ordinal()
r4 = r4[r5]
r5 = 1
if (r4 == r5) goto L63
r6 = 2
if (r4 == r6) goto L5e
r6 = 3
if (r4 != r6) goto L47
java.lang.String r1 = r8.nextString()
int r1 = java.lang.Integer.parseInt(r1) // Catch: java.lang.NumberFormatException -> L30
if (r1 == 0) goto L2e
goto L69
L2e:
r5 = 0
goto L69
L30:
com.google.gson.JsonSyntaxException r8 = new com.google.gson.JsonSyntaxException
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r2 = "Error: Expecting: bitset number value (1, 0), Found: "
r0.append(r2)
r0.append(r1)
java.lang.String r0 = r0.toString()
r8.<init>(r0)
throw r8
L47:
com.google.gson.JsonSyntaxException r8 = new com.google.gson.JsonSyntaxException
java.lang.StringBuilder r0 = new java.lang.StringBuilder
r0.<init>()
java.lang.String r2 = "Invalid bitset value type: "
r0.append(r2)
r0.append(r1)
java.lang.String r0 = r0.toString()
r8.<init>(r0)
throw r8
L5e:
boolean r5 = r8.nextBoolean()
goto L69
L63:
int r1 = r8.nextInt()
if (r1 == 0) goto L2e
L69:
if (r5 == 0) goto L6e
r0.set(r3)
L6e:
int r3 = r3 + 1
com.google.gson.stream.JsonToken r1 = r8.peek()
goto Le
L75:
r8.endArray()
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.gson.internal.bind.TypeAdapters.AnonymousClass2.read(com.google.gson.stream.JsonReader):java.util.BitSet");
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, BitSet bitSet) throws IOException {
jsonWriter.beginArray();
int length = bitSet.length();
for (int i = 0; i < length; i++) {
jsonWriter.value(bitSet.get(i) ? 1L : 0L);
}
jsonWriter.endArray();
}
}.nullSafe();
public static final TypeAdapterFactory BIT_SET_FACTORY = newFactory(BitSet.class, BIT_SET);
public static final TypeAdapter<Boolean> BOOLEAN = new TypeAdapter<Boolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.3
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Boolean read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return jsonReader.peek() == JsonToken.STRING ? Boolean.valueOf(Boolean.parseBoolean(jsonReader.nextString())) : Boolean.valueOf(jsonReader.nextBoolean());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Boolean bool) throws IOException {
jsonWriter.value(bool);
}
};
public static final TypeAdapter<Boolean> BOOLEAN_AS_STRING = new TypeAdapter<Boolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.4
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Boolean read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Boolean.valueOf(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Boolean bool) throws IOException {
jsonWriter.value(bool == null ? "null" : bool.toString());
}
};
public static final TypeAdapterFactory BOOLEAN_FACTORY = newFactory(Boolean.TYPE, Boolean.class, BOOLEAN);
public static final TypeAdapter<Number> BYTE = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.5
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return Byte.valueOf((byte) jsonReader.nextInt());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapterFactory BYTE_FACTORY = newFactory(Byte.TYPE, Byte.class, BYTE);
public static final TypeAdapter<Number> SHORT = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.6
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return Short.valueOf((short) jsonReader.nextInt());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapterFactory SHORT_FACTORY = newFactory(Short.TYPE, Short.class, SHORT);
public static final TypeAdapter<Number> INTEGER = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.7
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return Integer.valueOf(jsonReader.nextInt());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapterFactory INTEGER_FACTORY = newFactory(Integer.TYPE, Integer.class, INTEGER);
public static final TypeAdapter<AtomicInteger> ATOMIC_INTEGER = new TypeAdapter<AtomicInteger>() { // from class: com.google.gson.internal.bind.TypeAdapters.8
@Override // com.google.gson.TypeAdapter
public AtomicInteger read(JsonReader jsonReader) throws IOException {
try {
return new AtomicInteger(jsonReader.nextInt());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, AtomicInteger atomicInteger) throws IOException {
jsonWriter.value(atomicInteger.get());
}
}.nullSafe();
public static final TypeAdapterFactory ATOMIC_INTEGER_FACTORY = newFactory(AtomicInteger.class, ATOMIC_INTEGER);
public static final TypeAdapter<AtomicBoolean> ATOMIC_BOOLEAN = new TypeAdapter<AtomicBoolean>() { // from class: com.google.gson.internal.bind.TypeAdapters.9
@Override // com.google.gson.TypeAdapter
public AtomicBoolean read(JsonReader jsonReader) throws IOException {
return new AtomicBoolean(jsonReader.nextBoolean());
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, AtomicBoolean atomicBoolean) throws IOException {
jsonWriter.value(atomicBoolean.get());
}
}.nullSafe();
public static final TypeAdapterFactory ATOMIC_BOOLEAN_FACTORY = newFactory(AtomicBoolean.class, ATOMIC_BOOLEAN);
public static final TypeAdapter<AtomicIntegerArray> ATOMIC_INTEGER_ARRAY = new TypeAdapter<AtomicIntegerArray>() { // from class: com.google.gson.internal.bind.TypeAdapters.10
@Override // com.google.gson.TypeAdapter
public AtomicIntegerArray read(JsonReader jsonReader) throws IOException {
ArrayList arrayList = new ArrayList();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
try {
arrayList.add(Integer.valueOf(jsonReader.nextInt()));
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
jsonReader.endArray();
int size = arrayList.size();
AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(size);
for (int i = 0; i < size; i++) {
atomicIntegerArray.set(i, ((Integer) arrayList.get(i)).intValue());
}
return atomicIntegerArray;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, AtomicIntegerArray atomicIntegerArray) throws IOException {
jsonWriter.beginArray();
int length = atomicIntegerArray.length();
for (int i = 0; i < length; i++) {
jsonWriter.value(atomicIntegerArray.get(i));
}
jsonWriter.endArray();
}
}.nullSafe();
public static final TypeAdapterFactory ATOMIC_INTEGER_ARRAY_FACTORY = newFactory(AtomicIntegerArray.class, ATOMIC_INTEGER_ARRAY);
public static final TypeAdapter<Number> LONG = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.11
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return Long.valueOf(jsonReader.nextLong());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapter<Number> FLOAT = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.12
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Float.valueOf((float) jsonReader.nextDouble());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapter<Number> DOUBLE = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.13
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return Double.valueOf(jsonReader.nextDouble());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapter<Number> NUMBER = new TypeAdapter<Number>() { // from class: com.google.gson.internal.bind.TypeAdapters.14
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Number read(JsonReader jsonReader) throws IOException {
JsonToken peek = jsonReader.peek();
int i = AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken[peek.ordinal()];
if (i == 1 || i == 3) {
return new LazilyParsedNumber(jsonReader.nextString());
}
if (i == 4) {
jsonReader.nextNull();
return null;
}
throw new JsonSyntaxException("Expecting number, got: " + peek);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Number number) throws IOException {
jsonWriter.value(number);
}
};
public static final TypeAdapterFactory NUMBER_FACTORY = newFactory(Number.class, NUMBER);
public static final TypeAdapter<Character> CHARACTER = new TypeAdapter<Character>() { // from class: com.google.gson.internal.bind.TypeAdapters.15
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public Character read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
String nextString = jsonReader.nextString();
if (nextString.length() == 1) {
return Character.valueOf(nextString.charAt(0));
}
throw new JsonSyntaxException("Expecting character, got: " + nextString);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Character ch) throws IOException {
jsonWriter.value(ch == null ? null : String.valueOf(ch));
}
};
public static final TypeAdapterFactory CHARACTER_FACTORY = newFactory(Character.TYPE, Character.class, CHARACTER);
public static final TypeAdapter<String> STRING = new TypeAdapter<String>() { // from class: com.google.gson.internal.bind.TypeAdapters.16
@Override // com.google.gson.TypeAdapter
public String read(JsonReader jsonReader) throws IOException {
JsonToken peek = jsonReader.peek();
if (peek != JsonToken.NULL) {
return peek == JsonToken.BOOLEAN ? Boolean.toString(jsonReader.nextBoolean()) : jsonReader.nextString();
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, String str) throws IOException {
jsonWriter.value(str);
}
};
public static final TypeAdapter<BigDecimal> BIG_DECIMAL = new TypeAdapter<BigDecimal>() { // from class: com.google.gson.internal.bind.TypeAdapters.17
@Override // com.google.gson.TypeAdapter
public BigDecimal read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return new BigDecimal(jsonReader.nextString());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, BigDecimal bigDecimal) throws IOException {
jsonWriter.value(bigDecimal);
}
};
public static final TypeAdapter<BigInteger> BIG_INTEGER = new TypeAdapter<BigInteger>() { // from class: com.google.gson.internal.bind.TypeAdapters.18
@Override // com.google.gson.TypeAdapter
public BigInteger read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
return new BigInteger(jsonReader.nextString());
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, BigInteger bigInteger) throws IOException {
jsonWriter.value(bigInteger);
}
};
public static final TypeAdapterFactory STRING_FACTORY = newFactory(String.class, STRING);
public static final TypeAdapter<StringBuilder> STRING_BUILDER = new TypeAdapter<StringBuilder>() { // from class: com.google.gson.internal.bind.TypeAdapters.19
@Override // com.google.gson.TypeAdapter
public StringBuilder read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return new StringBuilder(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, StringBuilder sb) throws IOException {
jsonWriter.value(sb == null ? null : sb.toString());
}
};
public static final TypeAdapterFactory STRING_BUILDER_FACTORY = newFactory(StringBuilder.class, STRING_BUILDER);
public static final TypeAdapter<StringBuffer> STRING_BUFFER = new TypeAdapter<StringBuffer>() { // from class: com.google.gson.internal.bind.TypeAdapters.20
@Override // com.google.gson.TypeAdapter
public StringBuffer read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return new StringBuffer(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, StringBuffer stringBuffer) throws IOException {
jsonWriter.value(stringBuffer == null ? null : stringBuffer.toString());
}
};
public static final TypeAdapterFactory STRING_BUFFER_FACTORY = newFactory(StringBuffer.class, STRING_BUFFER);
public static final TypeAdapter<URL> URL = new TypeAdapter<URL>() { // from class: com.google.gson.internal.bind.TypeAdapters.21
@Override // com.google.gson.TypeAdapter
public URL read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
String nextString = jsonReader.nextString();
if ("null".equals(nextString)) {
return null;
}
return new URL(nextString);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, URL url) throws IOException {
jsonWriter.value(url == null ? null : url.toExternalForm());
}
};
public static final TypeAdapterFactory URL_FACTORY = newFactory(URL.class, URL);
public static final TypeAdapter<URI> URI = new TypeAdapter<URI>() { // from class: com.google.gson.internal.bind.TypeAdapters.22
@Override // com.google.gson.TypeAdapter
public URI read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
try {
String nextString = jsonReader.nextString();
if ("null".equals(nextString)) {
return null;
}
return new URI(nextString);
} catch (URISyntaxException e) {
throw new JsonIOException(e);
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, URI uri) throws IOException {
jsonWriter.value(uri == null ? null : uri.toASCIIString());
}
};
public static final TypeAdapterFactory URI_FACTORY = newFactory(URI.class, URI);
public static final TypeAdapter<InetAddress> INET_ADDRESS = new TypeAdapter<InetAddress>() { // from class: com.google.gson.internal.bind.TypeAdapters.23
@Override // com.google.gson.TypeAdapter
public InetAddress read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return InetAddress.getByName(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, InetAddress inetAddress) throws IOException {
jsonWriter.value(inetAddress == null ? null : inetAddress.getHostAddress());
}
};
public static final TypeAdapterFactory INET_ADDRESS_FACTORY = newTypeHierarchyFactory(InetAddress.class, INET_ADDRESS);
public static final TypeAdapter<UUID> UUID = new TypeAdapter<UUID>() { // from class: com.google.gson.internal.bind.TypeAdapters.24
@Override // com.google.gson.TypeAdapter
public UUID read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return UUID.fromString(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, UUID uuid) throws IOException {
jsonWriter.value(uuid == null ? null : uuid.toString());
}
};
public static final TypeAdapterFactory UUID_FACTORY = newFactory(UUID.class, UUID);
public static final TypeAdapter<Currency> CURRENCY = new TypeAdapter<Currency>() { // from class: com.google.gson.internal.bind.TypeAdapters.25
@Override // com.google.gson.TypeAdapter
public Currency read(JsonReader jsonReader) throws IOException {
return Currency.getInstance(jsonReader.nextString());
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Currency currency) throws IOException {
jsonWriter.value(currency.getCurrencyCode());
}
}.nullSafe();
public static final TypeAdapterFactory CURRENCY_FACTORY = newFactory(Currency.class, CURRENCY);
public static final TypeAdapterFactory TIMESTAMP_FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.26
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() != Timestamp.class) {
return null;
}
final TypeAdapter<T> adapter = gson.getAdapter(Date.class);
return (TypeAdapter<T>) new TypeAdapter<Timestamp>() { // from class: com.google.gson.internal.bind.TypeAdapters.26.1
@Override // com.google.gson.TypeAdapter
public Timestamp read(JsonReader jsonReader) throws IOException {
Date date = (Date) adapter.read(jsonReader);
if (date != null) {
return new Timestamp(date.getTime());
}
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Timestamp timestamp) throws IOException {
adapter.write(jsonWriter, timestamp);
}
};
}
};
public static final TypeAdapter<Calendar> CALENDAR = new TypeAdapter<Calendar>() { // from class: com.google.gson.internal.bind.TypeAdapters.27
private static final String DAY_OF_MONTH = "dayOfMonth";
private static final String HOUR_OF_DAY = "hourOfDay";
private static final String MINUTE = "minute";
private static final String MONTH = "month";
private static final String SECOND = "second";
private static final String YEAR = "year";
@Override // com.google.gson.TypeAdapter
public Calendar read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
jsonReader.beginObject();
int i = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = 0;
while (jsonReader.peek() != JsonToken.END_OBJECT) {
String nextName = jsonReader.nextName();
int nextInt = jsonReader.nextInt();
if (YEAR.equals(nextName)) {
i = nextInt;
} else if (MONTH.equals(nextName)) {
i2 = nextInt;
} else if (DAY_OF_MONTH.equals(nextName)) {
i3 = nextInt;
} else if (HOUR_OF_DAY.equals(nextName)) {
i4 = nextInt;
} else if (MINUTE.equals(nextName)) {
i5 = nextInt;
} else if (SECOND.equals(nextName)) {
i6 = nextInt;
}
}
jsonReader.endObject();
return new GregorianCalendar(i, i2, i3, i4, i5, i6);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Calendar calendar) throws IOException {
if (calendar == null) {
jsonWriter.nullValue();
return;
}
jsonWriter.beginObject();
jsonWriter.name(YEAR);
jsonWriter.value(calendar.get(1));
jsonWriter.name(MONTH);
jsonWriter.value(calendar.get(2));
jsonWriter.name(DAY_OF_MONTH);
jsonWriter.value(calendar.get(5));
jsonWriter.name(HOUR_OF_DAY);
jsonWriter.value(calendar.get(11));
jsonWriter.name(MINUTE);
jsonWriter.value(calendar.get(12));
jsonWriter.name(SECOND);
jsonWriter.value(calendar.get(13));
jsonWriter.endObject();
}
};
public static final TypeAdapterFactory CALENDAR_FACTORY = newFactoryForMultipleTypes(Calendar.class, GregorianCalendar.class, CALENDAR);
public static final TypeAdapter<Locale> LOCALE = new TypeAdapter<Locale>() { // from class: com.google.gson.internal.bind.TypeAdapters.28
@Override // com.google.gson.TypeAdapter
public Locale read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() == JsonToken.NULL) {
jsonReader.nextNull();
return null;
}
StringTokenizer stringTokenizer = new StringTokenizer(jsonReader.nextString(), "_");
String nextToken = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
String nextToken2 = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
String nextToken3 = stringTokenizer.hasMoreElements() ? stringTokenizer.nextToken() : null;
return (nextToken2 == null && nextToken3 == null) ? new Locale(nextToken) : nextToken3 == null ? new Locale(nextToken, nextToken2) : new Locale(nextToken, nextToken2, nextToken3);
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, Locale locale) throws IOException {
jsonWriter.value(locale == null ? null : locale.toString());
}
};
public static final TypeAdapterFactory LOCALE_FACTORY = newFactory(Locale.class, LOCALE);
public static final TypeAdapter<JsonElement> JSON_ELEMENT = new TypeAdapter<JsonElement>() { // from class: com.google.gson.internal.bind.TypeAdapters.29
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.google.gson.TypeAdapter
public JsonElement read(JsonReader jsonReader) throws IOException {
switch (AnonymousClass36.$SwitchMap$com$google$gson$stream$JsonToken[jsonReader.peek().ordinal()]) {
case 1:
return new JsonPrimitive((Number) new LazilyParsedNumber(jsonReader.nextString()));
case 2:
return new JsonPrimitive(Boolean.valueOf(jsonReader.nextBoolean()));
case 3:
return new JsonPrimitive(jsonReader.nextString());
case 4:
jsonReader.nextNull();
return JsonNull.INSTANCE;
case 5:
JsonArray jsonArray = new JsonArray();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
jsonArray.add(read(jsonReader));
}
jsonReader.endArray();
return jsonArray;
case 6:
JsonObject jsonObject = new JsonObject();
jsonReader.beginObject();
while (jsonReader.hasNext()) {
jsonObject.add(jsonReader.nextName(), read(jsonReader));
}
jsonReader.endObject();
return jsonObject;
default:
throw new IllegalArgumentException();
}
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, JsonElement jsonElement) throws IOException {
if (jsonElement == null || jsonElement.isJsonNull()) {
jsonWriter.nullValue();
return;
}
if (jsonElement.isJsonPrimitive()) {
JsonPrimitive asJsonPrimitive = jsonElement.getAsJsonPrimitive();
if (asJsonPrimitive.isNumber()) {
jsonWriter.value(asJsonPrimitive.getAsNumber());
return;
} else if (asJsonPrimitive.isBoolean()) {
jsonWriter.value(asJsonPrimitive.getAsBoolean());
return;
} else {
jsonWriter.value(asJsonPrimitive.getAsString());
return;
}
}
if (jsonElement.isJsonArray()) {
jsonWriter.beginArray();
Iterator<JsonElement> it = jsonElement.getAsJsonArray().iterator();
while (it.hasNext()) {
write(jsonWriter, it.next());
}
jsonWriter.endArray();
return;
}
if (!jsonElement.isJsonObject()) {
throw new IllegalArgumentException("Couldn't write " + jsonElement.getClass());
}
jsonWriter.beginObject();
for (Map.Entry<String, JsonElement> entry : jsonElement.getAsJsonObject().entrySet()) {
jsonWriter.name(entry.getKey());
write(jsonWriter, entry.getValue());
}
jsonWriter.endObject();
}
};
public static final TypeAdapterFactory JSON_ELEMENT_FACTORY = newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT);
public static final TypeAdapterFactory ENUM_FACTORY = new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.30
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (!Enum.class.isAssignableFrom(rawType) || rawType == Enum.class) {
return null;
}
if (!rawType.isEnum()) {
rawType = rawType.getSuperclass();
}
return new EnumTypeAdapter(rawType);
}
};
/* renamed from: com.google.gson.internal.bind.TypeAdapters$36, reason: invalid class name */
static /* synthetic */ class AnonymousClass36 {
static final /* synthetic */ int[] $SwitchMap$com$google$gson$stream$JsonToken = new int[JsonToken.values().length];
static {
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NUMBER.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BOOLEAN.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.STRING.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NULL.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_ARRAY.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.BEGIN_OBJECT.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_DOCUMENT.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.NAME.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_OBJECT.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$google$gson$stream$JsonToken[JsonToken.END_ARRAY.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
}
}
private static final class EnumTypeAdapter<T extends Enum<T>> extends TypeAdapter<T> {
private final Map<String, T> nameToConstant = new HashMap();
private final Map<T, String> constantToName = new HashMap();
public EnumTypeAdapter(Class<T> cls) {
try {
for (T t : cls.getEnumConstants()) {
String name = t.name();
SerializedName serializedName = (SerializedName) cls.getField(name).getAnnotation(SerializedName.class);
if (serializedName != null) {
name = serializedName.value();
for (String str : serializedName.alternate()) {
this.nameToConstant.put(str, t);
}
}
this.nameToConstant.put(name, t);
this.constantToName.put(t, name);
}
} catch (NoSuchFieldException e) {
throw new AssertionError(e);
}
}
@Override // com.google.gson.TypeAdapter
public T read(JsonReader jsonReader) throws IOException {
if (jsonReader.peek() != JsonToken.NULL) {
return this.nameToConstant.get(jsonReader.nextString());
}
jsonReader.nextNull();
return null;
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T t) throws IOException {
jsonWriter.value(t == null ? null : this.constantToName.get(t));
}
}
private TypeAdapters() {
throw new UnsupportedOperationException();
}
public static <TT> TypeAdapterFactory newFactory(final TypeToken<TT> typeToken, final TypeAdapter<TT> typeAdapter) {
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.31
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken2) {
if (typeToken2.equals(TypeToken.this)) {
return typeAdapter;
}
return null;
}
};
}
public static <TT> TypeAdapterFactory newFactoryForMultipleTypes(final Class<TT> cls, final Class<? extends TT> cls2, final TypeAdapter<? super TT> typeAdapter) {
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.34
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (rawType == cls || rawType == cls2) {
return typeAdapter;
}
return null;
}
public String toString() {
return "Factory[type=" + cls.getName() + "+" + cls2.getName() + ",adapter=" + typeAdapter + "]";
}
};
}
public static <T1> TypeAdapterFactory newTypeHierarchyFactory(final Class<T1> cls, final TypeAdapter<T1> typeAdapter) {
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.35
@Override // com.google.gson.TypeAdapterFactory
public <T2> TypeAdapter<T2> create(Gson gson, TypeToken<T2> typeToken) {
final Class<? super T2> rawType = typeToken.getRawType();
if (cls.isAssignableFrom(rawType)) {
return (TypeAdapter<T2>) new TypeAdapter<T1>() { // from class: com.google.gson.internal.bind.TypeAdapters.35.1
@Override // com.google.gson.TypeAdapter
public T1 read(JsonReader jsonReader) throws IOException {
T1 t1 = (T1) typeAdapter.read(jsonReader);
if (t1 == null || rawType.isInstance(t1)) {
return t1;
}
throw new JsonSyntaxException("Expected a " + rawType.getName() + " but was " + t1.getClass().getName());
}
@Override // com.google.gson.TypeAdapter
public void write(JsonWriter jsonWriter, T1 t1) throws IOException {
typeAdapter.write(jsonWriter, t1);
}
};
}
return null;
}
public String toString() {
return "Factory[typeHierarchy=" + cls.getName() + ",adapter=" + typeAdapter + "]";
}
};
}
public static <TT> TypeAdapterFactory newFactory(final Class<TT> cls, final TypeAdapter<TT> typeAdapter) {
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.32
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() == cls) {
return typeAdapter;
}
return null;
}
public String toString() {
return "Factory[type=" + cls.getName() + ",adapter=" + typeAdapter + "]";
}
};
}
public static <TT> TypeAdapterFactory newFactory(final Class<TT> cls, final Class<TT> cls2, final TypeAdapter<? super TT> typeAdapter) {
return new TypeAdapterFactory() { // from class: com.google.gson.internal.bind.TypeAdapters.33
@Override // com.google.gson.TypeAdapterFactory
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Class<? super T> rawType = typeToken.getRawType();
if (rawType == cls || rawType == cls2) {
return typeAdapter;
}
return null;
}
public String toString() {
return "Factory[type=" + cls2.getName() + "+" + cls.getName() + ",adapter=" + typeAdapter + "]";
}
};
}
}

View File

@@ -0,0 +1,120 @@
package com.google.gson.internal.bind.util;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
/* loaded from: classes.dex */
public class ISO8601Utils {
private static final String UTC_ID = "UTC";
private static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone(UTC_ID);
private static boolean checkOffset(String str, int i, char c) {
return i < str.length() && str.charAt(i) == c;
}
public static String format(Date date) {
return format(date, false, TIMEZONE_UTC);
}
private static int indexOfNonDigit(String str, int i) {
while (i < str.length()) {
char charAt = str.charAt(i);
if (charAt < '0' || charAt > '9') {
return i;
}
i++;
}
return str.length();
}
private static void padInt(StringBuilder sb, int i, int i2) {
String num = Integer.toString(i);
for (int length = i2 - num.length(); length > 0; length--) {
sb.append('0');
}
sb.append(num);
}
/* JADX WARN: Removed duplicated region for block: B:44:0x00cc A[Catch: IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, NumberFormatException -> 0x01bd, IndexOutOfBoundsException -> 0x01bf, TryCatch #2 {IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, blocks: (B:3:0x0006, B:5:0x0018, B:6:0x001a, B:8:0x0026, B:9:0x0028, B:11:0x0037, B:13:0x003d, B:18:0x0052, B:20:0x0062, B:21:0x0064, B:23:0x0070, B:24:0x0072, B:26:0x0078, B:30:0x0082, B:35:0x0094, B:37:0x009c, B:42:0x00c6, B:44:0x00cc, B:46:0x00d3, B:47:0x0181, B:53:0x00df, B:54:0x00f8, B:55:0x00f9, B:58:0x0115, B:60:0x0122, B:63:0x012b, B:65:0x014a, B:68:0x0159, B:69:0x017b, B:71:0x017e, B:72:0x0104, B:73:0x01b3, B:74:0x01ba, B:75:0x00b4, B:76:0x00b7), top: B:2:0x0006 }] */
/* JADX WARN: Removed duplicated region for block: B:73:0x01b3 A[Catch: IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, NumberFormatException -> 0x01bd, IndexOutOfBoundsException -> 0x01bf, TryCatch #2 {IllegalArgumentException | IndexOutOfBoundsException | NumberFormatException -> 0x01bb, blocks: (B:3:0x0006, B:5:0x0018, B:6:0x001a, B:8:0x0026, B:9:0x0028, B:11:0x0037, B:13:0x003d, B:18:0x0052, B:20:0x0062, B:21:0x0064, B:23:0x0070, B:24:0x0072, B:26:0x0078, B:30:0x0082, B:35:0x0094, B:37:0x009c, B:42:0x00c6, B:44:0x00cc, B:46:0x00d3, B:47:0x0181, B:53:0x00df, B:54:0x00f8, B:55:0x00f9, B:58:0x0115, B:60:0x0122, B:63:0x012b, B:65:0x014a, B:68:0x0159, B:69:0x017b, B:71:0x017e, B:72:0x0104, B:73:0x01b3, B:74:0x01ba, B:75:0x00b4, B:76:0x00b7), top: B:2:0x0006 }] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public static java.util.Date parse(java.lang.String r18, java.text.ParsePosition r19) throws java.text.ParseException {
/*
Method dump skipped, instructions count: 552
To view this dump change 'Code comments level' option to 'DEBUG'
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.gson.internal.bind.util.ISO8601Utils.parse(java.lang.String, java.text.ParsePosition):java.util.Date");
}
private static int parseInt(String str, int i, int i2) throws NumberFormatException {
int i3;
int i4;
if (i < 0 || i2 > str.length() || i > i2) {
throw new NumberFormatException(str);
}
if (i < i2) {
i3 = i + 1;
int digit = Character.digit(str.charAt(i), 10);
if (digit < 0) {
throw new NumberFormatException("Invalid number: " + str.substring(i, i2));
}
i4 = -digit;
} else {
i3 = i;
i4 = 0;
}
while (i3 < i2) {
int i5 = i3 + 1;
int digit2 = Character.digit(str.charAt(i3), 10);
if (digit2 < 0) {
throw new NumberFormatException("Invalid number: " + str.substring(i, i2));
}
i4 = (i4 * 10) - digit2;
i3 = i5;
}
return -i4;
}
public static String format(Date date, boolean z) {
return format(date, z, TIMEZONE_UTC);
}
public static String format(Date date, boolean z, TimeZone timeZone) {
GregorianCalendar gregorianCalendar = new GregorianCalendar(timeZone, Locale.US);
gregorianCalendar.setTime(date);
StringBuilder sb = new StringBuilder(19 + (z ? 4 : 0) + (timeZone.getRawOffset() == 0 ? 1 : 6));
padInt(sb, gregorianCalendar.get(1), 4);
sb.append('-');
padInt(sb, gregorianCalendar.get(2) + 1, 2);
sb.append('-');
padInt(sb, gregorianCalendar.get(5), 2);
sb.append('T');
padInt(sb, gregorianCalendar.get(11), 2);
sb.append(':');
padInt(sb, gregorianCalendar.get(12), 2);
sb.append(':');
padInt(sb, gregorianCalendar.get(13), 2);
if (z) {
sb.append('.');
padInt(sb, gregorianCalendar.get(14), 3);
}
int offset = timeZone.getOffset(gregorianCalendar.getTimeInMillis());
if (offset != 0) {
int i = offset / 60000;
int abs = Math.abs(i / 60);
int abs2 = Math.abs(i % 60);
sb.append(offset >= 0 ? '+' : '-');
padInt(sb, abs, 2);
sb.append(':');
padInt(sb, abs2, 2);
} else {
sb.append('Z');
}
return sb.toString();
}
}

View File

@@ -0,0 +1,191 @@
package com.google.gson.reflect;
import com.google.gson.internal.C$Gson$Preconditions;
import com.google.gson.internal.C$Gson$Types;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes.dex */
public class TypeToken<T> {
final int hashCode;
final Class<? super T> rawType;
final Type type;
protected TypeToken() {
this.type = getSuperclassTypeParameter(getClass());
this.rawType = (Class<? super T>) C$Gson$Types.getRawType(this.type);
this.hashCode = this.type.hashCode();
}
private static AssertionError buildUnexpectedTypeError(Type type, Class<?>... clsArr) {
StringBuilder sb = new StringBuilder("Unexpected type. Expected one of: ");
for (Class<?> cls : clsArr) {
sb.append(cls.getName());
sb.append(", ");
}
sb.append("but got: ");
sb.append(type.getClass().getName());
sb.append(", for type token: ");
sb.append(type.toString());
sb.append('.');
return new AssertionError(sb.toString());
}
public static TypeToken<?> get(Type type) {
return new TypeToken<>(type);
}
public static TypeToken<?> getArray(Type type) {
return new TypeToken<>(C$Gson$Types.arrayOf(type));
}
public static TypeToken<?> getParameterized(Type type, Type... typeArr) {
return new TypeToken<>(C$Gson$Types.newParameterizedTypeWithOwner(null, type, typeArr));
}
static Type getSuperclassTypeParameter(Class<?> cls) {
Type genericSuperclass = cls.getGenericSuperclass();
if (genericSuperclass instanceof Class) {
throw new RuntimeException("Missing type parameter.");
}
return C$Gson$Types.canonicalize(((ParameterizedType) genericSuperclass).getActualTypeArguments()[0]);
}
private static boolean matches(Type type, Type type2, Map<String, Type> map) {
return type2.equals(type) || ((type instanceof TypeVariable) && type2.equals(map.get(((TypeVariable) type).getName())));
}
private static boolean typeEquals(ParameterizedType parameterizedType, ParameterizedType parameterizedType2, Map<String, Type> map) {
if (!parameterizedType.getRawType().equals(parameterizedType2.getRawType())) {
return false;
}
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
Type[] actualTypeArguments2 = parameterizedType2.getActualTypeArguments();
for (int i = 0; i < actualTypeArguments.length; i++) {
if (!matches(actualTypeArguments[i], actualTypeArguments2[i], map)) {
return false;
}
}
return true;
}
public final boolean equals(Object obj) {
return (obj instanceof TypeToken) && C$Gson$Types.equals(this.type, ((TypeToken) obj).type);
}
public final Class<? super T> getRawType() {
return this.rawType;
}
public final Type getType() {
return this.type;
}
public final int hashCode() {
return this.hashCode;
}
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
return isAssignableFrom((Type) cls);
}
public final String toString() {
return C$Gson$Types.typeToString(this.type);
}
public static <T> TypeToken<T> get(Class<T> cls) {
return new TypeToken<>(cls);
}
@Deprecated
public boolean isAssignableFrom(Type type) {
if (type == null) {
return false;
}
if (this.type.equals(type)) {
return true;
}
Type type2 = this.type;
if (type2 instanceof Class) {
return this.rawType.isAssignableFrom(C$Gson$Types.getRawType(type));
}
if (type2 instanceof ParameterizedType) {
return isAssignableFrom(type, (ParameterizedType) type2, new HashMap());
}
if (type2 instanceof GenericArrayType) {
return this.rawType.isAssignableFrom(C$Gson$Types.getRawType(type)) && isAssignableFrom(type, (GenericArrayType) this.type);
}
throw buildUnexpectedTypeError(type2, Class.class, ParameterizedType.class, GenericArrayType.class);
}
TypeToken(Type type) {
this.type = C$Gson$Types.canonicalize((Type) C$Gson$Preconditions.checkNotNull(type));
this.rawType = (Class<? super T>) C$Gson$Types.getRawType(this.type);
this.hashCode = this.type.hashCode();
}
@Deprecated
public boolean isAssignableFrom(TypeToken<?> typeToken) {
return isAssignableFrom(typeToken.getType());
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r1v0, types: [java.lang.reflect.Type] */
/* JADX WARN: Type inference failed for: r1v10 */
/* JADX WARN: Type inference failed for: r1v3, types: [java.lang.Class] */
/* JADX WARN: Type inference failed for: r1v5, types: [java.lang.reflect.Type] */
/* JADX WARN: Type inference failed for: r1v8, types: [java.lang.reflect.Type] */
/* JADX WARN: Type inference failed for: r1v9 */
private static boolean isAssignableFrom(Type type, GenericArrayType genericArrayType) {
Type genericComponentType = genericArrayType.getGenericComponentType();
if (!(genericComponentType instanceof ParameterizedType)) {
return true;
}
if (type instanceof GenericArrayType) {
type = ((GenericArrayType) type).getGenericComponentType();
} else if (type instanceof Class) {
type = (Class) type;
while (type.isArray()) {
type = type.getComponentType();
}
}
return isAssignableFrom(type, (ParameterizedType) genericComponentType, new HashMap());
}
private static boolean isAssignableFrom(Type type, ParameterizedType parameterizedType, Map<String, Type> map) {
if (type == null) {
return false;
}
if (parameterizedType.equals(type)) {
return true;
}
Class<?> rawType = C$Gson$Types.getRawType(type);
ParameterizedType parameterizedType2 = type instanceof ParameterizedType ? (ParameterizedType) type : null;
if (parameterizedType2 != null) {
Type[] actualTypeArguments = parameterizedType2.getActualTypeArguments();
TypeVariable<Class<?>>[] typeParameters = rawType.getTypeParameters();
for (int i = 0; i < actualTypeArguments.length; i++) {
Type type2 = actualTypeArguments[i];
TypeVariable<Class<?>> typeVariable = typeParameters[i];
while (type2 instanceof TypeVariable) {
type2 = map.get(((TypeVariable) type2).getName());
}
map.put(typeVariable.getName(), type2);
}
if (typeEquals(parameterizedType2, parameterizedType, map)) {
return true;
}
}
for (Type type3 : rawType.getGenericInterfaces()) {
if (isAssignableFrom(type3, parameterizedType, new HashMap(map))) {
return true;
}
}
return isAssignableFrom(rawType.getGenericSuperclass(), parameterizedType, new HashMap(map));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
package com.google.gson.stream;
/* loaded from: classes.dex */
final class JsonScope {
static final int CLOSED = 8;
static final int DANGLING_NAME = 4;
static final int EMPTY_ARRAY = 1;
static final int EMPTY_DOCUMENT = 6;
static final int EMPTY_OBJECT = 3;
static final int NONEMPTY_ARRAY = 2;
static final int NONEMPTY_DOCUMENT = 7;
static final int NONEMPTY_OBJECT = 5;
JsonScope() {
}
}

View File

@@ -0,0 +1,15 @@
package com.google.gson.stream;
/* loaded from: classes.dex */
public enum JsonToken {
BEGIN_ARRAY,
END_ARRAY,
BEGIN_OBJECT,
END_OBJECT,
NAME,
STRING,
NUMBER,
BOOLEAN,
NULL,
END_DOCUMENT
}

View File

@@ -0,0 +1,389 @@
package com.google.gson.stream;
import com.tencent.bugly.Bugly;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;
/* loaded from: classes.dex */
public class JsonWriter implements Closeable, Flushable {
private static final String[] HTML_SAFE_REPLACEMENT_CHARS;
private static final String[] REPLACEMENT_CHARS = new String[PeripheralType.SERVO];
private String deferredName;
private boolean htmlSafe;
private String indent;
private boolean lenient;
private final Writer out;
private String separator;
private boolean serializeNulls;
private int[] stack = new int[32];
private int stackSize = 0;
static {
for (int i = 0; i <= 31; i++) {
REPLACEMENT_CHARS[i] = String.format("\\u%04x", Integer.valueOf(i));
}
String[] strArr = REPLACEMENT_CHARS;
strArr[34] = "\\\"";
strArr[92] = "\\\\";
strArr[9] = "\\t";
strArr[8] = "\\b";
strArr[10] = "\\n";
strArr[13] = "\\r";
strArr[12] = "\\f";
HTML_SAFE_REPLACEMENT_CHARS = (String[]) strArr.clone();
String[] strArr2 = HTML_SAFE_REPLACEMENT_CHARS;
strArr2[60] = "\\u003c";
strArr2[62] = "\\u003e";
strArr2[38] = "\\u0026";
strArr2[61] = "\\u003d";
strArr2[39] = "\\u0027";
}
public JsonWriter(Writer writer) {
push(6);
this.separator = ":";
this.serializeNulls = true;
if (writer == null) {
throw new NullPointerException("out == null");
}
this.out = writer;
}
private void beforeName() throws IOException {
int peek = peek();
if (peek == 5) {
this.out.write(44);
} else if (peek != 3) {
throw new IllegalStateException("Nesting problem.");
}
newline();
replaceTop(4);
}
private void beforeValue() throws IOException {
int peek = peek();
if (peek == 1) {
replaceTop(2);
newline();
return;
}
if (peek == 2) {
this.out.append(',');
newline();
} else {
if (peek == 4) {
this.out.append((CharSequence) this.separator);
replaceTop(5);
return;
}
if (peek != 6) {
if (peek != 7) {
throw new IllegalStateException("Nesting problem.");
}
if (!this.lenient) {
throw new IllegalStateException("JSON must have only one top-level value.");
}
}
replaceTop(7);
}
}
private JsonWriter close(int i, int i2, String str) throws IOException {
int peek = peek();
if (peek != i2 && peek != i) {
throw new IllegalStateException("Nesting problem.");
}
if (this.deferredName != null) {
throw new IllegalStateException("Dangling name: " + this.deferredName);
}
this.stackSize--;
if (peek == i2) {
newline();
}
this.out.write(str);
return this;
}
private void newline() throws IOException {
if (this.indent == null) {
return;
}
this.out.write("\n");
int i = this.stackSize;
for (int i2 = 1; i2 < i; i2++) {
this.out.write(this.indent);
}
}
private JsonWriter open(int i, String str) throws IOException {
beforeValue();
push(i);
this.out.write(str);
return this;
}
private int peek() {
int i = this.stackSize;
if (i != 0) {
return this.stack[i - 1];
}
throw new IllegalStateException("JsonWriter is closed.");
}
private void push(int i) {
int i2 = this.stackSize;
int[] iArr = this.stack;
if (i2 == iArr.length) {
int[] iArr2 = new int[i2 * 2];
System.arraycopy(iArr, 0, iArr2, 0, i2);
this.stack = iArr2;
}
int[] iArr3 = this.stack;
int i3 = this.stackSize;
this.stackSize = i3 + 1;
iArr3[i3] = i;
}
private void replaceTop(int i) {
this.stack[this.stackSize - 1] = i;
}
/* JADX WARN: Removed duplicated region for block: B:11:0x0034 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private void string(java.lang.String r9) throws java.io.IOException {
/*
r8 = this;
boolean r0 = r8.htmlSafe
if (r0 == 0) goto L7
java.lang.String[] r0 = com.google.gson.stream.JsonWriter.HTML_SAFE_REPLACEMENT_CHARS
goto L9
L7:
java.lang.String[] r0 = com.google.gson.stream.JsonWriter.REPLACEMENT_CHARS
L9:
java.io.Writer r1 = r8.out
java.lang.String r2 = "\""
r1.write(r2)
int r1 = r9.length()
r3 = 0
r4 = 0
L16:
if (r3 >= r1) goto L45
char r5 = r9.charAt(r3)
r6 = 128(0x80, float:1.8E-43)
if (r5 >= r6) goto L25
r5 = r0[r5]
if (r5 != 0) goto L32
goto L42
L25:
r6 = 8232(0x2028, float:1.1535E-41)
if (r5 != r6) goto L2c
java.lang.String r5 = "\\u2028"
goto L32
L2c:
r6 = 8233(0x2029, float:1.1537E-41)
if (r5 != r6) goto L42
java.lang.String r5 = "\\u2029"
L32:
if (r4 >= r3) goto L3b
java.io.Writer r6 = r8.out
int r7 = r3 - r4
r6.write(r9, r4, r7)
L3b:
java.io.Writer r4 = r8.out
r4.write(r5)
int r4 = r3 + 1
L42:
int r3 = r3 + 1
goto L16
L45:
if (r4 >= r1) goto L4d
java.io.Writer r0 = r8.out
int r1 = r1 - r4
r0.write(r9, r4, r1)
L4d:
java.io.Writer r9 = r8.out
r9.write(r2)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.gson.stream.JsonWriter.string(java.lang.String):void");
}
private void writeDeferredName() throws IOException {
if (this.deferredName != null) {
beforeName();
string(this.deferredName);
this.deferredName = null;
}
}
public JsonWriter beginArray() throws IOException {
writeDeferredName();
return open(1, "[");
}
public JsonWriter beginObject() throws IOException {
writeDeferredName();
return open(3, "{");
}
public JsonWriter endArray() throws IOException {
return close(1, 2, "]");
}
public JsonWriter endObject() throws IOException {
return close(3, 5, "}");
}
public void flush() throws IOException {
if (this.stackSize == 0) {
throw new IllegalStateException("JsonWriter is closed.");
}
this.out.flush();
}
public final boolean getSerializeNulls() {
return this.serializeNulls;
}
public final boolean isHtmlSafe() {
return this.htmlSafe;
}
public boolean isLenient() {
return this.lenient;
}
public JsonWriter jsonValue(String str) throws IOException {
if (str == null) {
return nullValue();
}
writeDeferredName();
beforeValue();
this.out.append((CharSequence) str);
return this;
}
public JsonWriter name(String str) throws IOException {
if (str == null) {
throw new NullPointerException("name == null");
}
if (this.deferredName != null) {
throw new IllegalStateException();
}
if (this.stackSize == 0) {
throw new IllegalStateException("JsonWriter is closed.");
}
this.deferredName = str;
return this;
}
public JsonWriter nullValue() throws IOException {
if (this.deferredName != null) {
if (!this.serializeNulls) {
this.deferredName = null;
return this;
}
writeDeferredName();
}
beforeValue();
this.out.write("null");
return this;
}
public final void setHtmlSafe(boolean z) {
this.htmlSafe = z;
}
public final void setIndent(String str) {
if (str.length() == 0) {
this.indent = null;
this.separator = ":";
} else {
this.indent = str;
this.separator = ": ";
}
}
public final void setLenient(boolean z) {
this.lenient = z;
}
public final void setSerializeNulls(boolean z) {
this.serializeNulls = z;
}
public JsonWriter value(String str) throws IOException {
if (str == null) {
return nullValue();
}
writeDeferredName();
beforeValue();
string(str);
return this;
}
public JsonWriter value(boolean z) throws IOException {
writeDeferredName();
beforeValue();
this.out.write(z ? "true" : Bugly.SDK_IS_DEV);
return this;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.out.close();
int i = this.stackSize;
if (i <= 1 && (i != 1 || this.stack[i - 1] == 7)) {
this.stackSize = 0;
return;
}
throw new IOException("Incomplete document");
}
public JsonWriter value(Boolean bool) throws IOException {
if (bool == null) {
return nullValue();
}
writeDeferredName();
beforeValue();
this.out.write(bool.booleanValue() ? "true" : Bugly.SDK_IS_DEV);
return this;
}
public JsonWriter value(double d) throws IOException {
writeDeferredName();
if (!this.lenient && (Double.isNaN(d) || Double.isInfinite(d))) {
throw new IllegalArgumentException("Numeric values must be finite, but was " + d);
}
beforeValue();
this.out.append((CharSequence) Double.toString(d));
return this;
}
public JsonWriter value(long j) throws IOException {
writeDeferredName();
beforeValue();
this.out.write(Long.toString(j));
return this;
}
public JsonWriter value(Number number) throws IOException {
if (number == null) {
return nullValue();
}
writeDeferredName();
String obj = number.toString();
if (!this.lenient && (obj.equals("-Infinity") || obj.equals("Infinity") || obj.equals("NaN"))) {
throw new IllegalArgumentException("Numeric values must be finite, but was " + number);
}
beforeValue();
this.out.append((CharSequence) obj);
return this;
}
}

View File

@@ -0,0 +1,21 @@
package com.google.gson.stream;
import java.io.IOException;
/* loaded from: classes.dex */
public final class MalformedJsonException extends IOException {
private static final long serialVersionUID = 1;
public MalformedJsonException(String str) {
super(str);
}
public MalformedJsonException(String str, Throwable th) {
super(str);
initCause(th);
}
public MalformedJsonException(Throwable th) {
initCause(th);
}
}