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,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();
}
}