what-the-bank/sources/o/fRC.java

79 lines
2.5 KiB
Java

package o;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
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.JsonWriter;
import java.io.IOException;
import java.util.Map;
/* loaded from: classes6.dex */
public final class fRC<T> implements TypeAdapterFactory {
private final Map<Class<T>, fRG<T, String>> a;
public fRC(Map<Class<T>, fRG<T, String>> map) {
this.a = map;
}
@Override // com.google.gson.TypeAdapterFactory
public final <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
fRG<T, String> frg;
TypeAdapter<T> delegateAdapter = gson.getDelegateAdapter(this, typeToken);
Class<? super T> rawType = typeToken.getRawType();
while (true) {
if (rawType == null) {
frg = null;
break;
}
frg = this.a.get(rawType);
if (frg != null) {
break;
}
rawType = rawType.getSuperclass();
}
return frg == null ? delegateAdapter : new fRA(new LWm(this, frg, gson, delegateAdapter));
}
/* loaded from: classes6.dex */
class LWm<T> extends TypeAdapter<T> {
private final Gson a;
private fRC b;
private final fRG<T, String> c;
private final TypeAdapter<T> d;
public LWm(fRC frc, fRG<T, String> frg, Gson gson, TypeAdapter<T> typeAdapter) {
this.b = frc;
this.c = frg;
this.a = gson;
this.d = typeAdapter;
}
@Override // com.google.gson.TypeAdapter
public final void write(JsonWriter jsonWriter, T t) throws IOException {
if (t == null) {
this.d.write(jsonWriter, t);
return;
}
String b = this.c.b();
JsonElement jsonTree = this.d.toJsonTree(t);
JsonObject jsonObject = new JsonObject();
jsonObject.add(b, jsonTree);
this.a.toJson(jsonObject, jsonWriter);
}
@Override // com.google.gson.TypeAdapter
/* renamed from: read */
public final T read2(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
jsonReader.nextName();
T read2 = this.d.read2(jsonReader);
jsonReader.endObject();
return read2;
}
}
}