package com.discord.api.localizedstring; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import d0.t.h0; import d0.z.d.m; import java.util.HashMap; import java.util.Map; /* compiled from: LocalizedString.kt */ public final class LocalizedStringTypeAdapter extends TypeAdapter { public final /* synthetic */ class WhenMappings { public static final /* synthetic */ int[] $EnumSwitchMapping$0; static { JsonToken.values(); int[] iArr = new int[10]; $EnumSwitchMapping$0 = iArr; iArr[2] = 1; iArr[5] = 2; } } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // com.google.gson.TypeAdapter public LocalizedString read(JsonReader jsonReader) { m.checkNotNullParameter(jsonReader, "in"); JsonToken N = jsonReader.N(); if (N != null) { int ordinal = N.ordinal(); if (ordinal == 2) { jsonReader.b(); HashMap hashMap = new HashMap(); String str = ""; while (jsonReader.r()) { String C = jsonReader.C(); if (C != null) { int hashCode = C.hashCode(); if (hashCode != 597626106) { if (hashCode == 1544803905 && C.equals("default")) { str = jsonReader.K(); m.checkNotNullExpressionValue(str, "`in`.nextString()"); } } else if (C.equals("localizations")) { jsonReader.b(); while (jsonReader.r()) { String C2 = jsonReader.C(); String K = jsonReader.K(); m.checkNotNullExpressionValue(C2, "locale"); m.checkNotNullExpressionValue(K, "localization"); hashMap.put(C2, K); } jsonReader.f(); } } } jsonReader.f(); return new LocalizedString(str, hashMap); } else if (ordinal == 5) { String K2 = jsonReader.K(); m.checkNotNullExpressionValue(K2, "default"); return new LocalizedString(K2, h0.emptyMap()); } } throw new IllegalArgumentException("could not parse localized string. token was: " + N); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [com.google.gson.stream.JsonWriter, java.lang.Object] */ @Override // com.google.gson.TypeAdapter public void write(JsonWriter jsonWriter, LocalizedString localizedString) { LocalizedString localizedString2 = localizedString; m.checkNotNullParameter(jsonWriter, "out"); if (localizedString2 != null) { jsonWriter.c(); jsonWriter.p("default"); jsonWriter.H(localizedString2.a()); jsonWriter.p("localizations"); jsonWriter.c(); for (Map.Entry entry : localizedString2.b().entrySet()) { jsonWriter.p(entry.getKey()); jsonWriter.H(entry.getValue()); } jsonWriter.f(); jsonWriter.f(); return; } jsonWriter.s(); } }