discord-jadx/app/src/main/java/com/discord/api/auth/OAuthScopeTypeAdapter.java
2021-06-27 22:44:35 +02:00

74 lines
2.6 KiB
Java

package com.discord.api.auth;
import com.discord.api.auth.OAuthScope;
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.e0.c;
import d0.z.d.a0;
import d0.z.d.m;
import java.util.HashMap;
import java.util.Objects;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: OAuthScopeTypeAdapter.kt */
public final class OAuthScopeTypeAdapter extends TypeAdapter<OAuthScope> {
public static final Companion Companion = new Companion(null);
private static final HashMap<String, OAuthScope> nameToScopeMap;
/* compiled from: OAuthScopeTypeAdapter.kt */
public static final class Companion {
public Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
}
}
static {
HashMap<String, OAuthScope> hashMap = new HashMap<>();
for (c cVar : a0.getOrCreateKotlinClass(OAuthScope.class).getSealedSubclasses()) {
if (cVar.getObjectInstance() != null) {
Object objectInstance = cVar.getObjectInstance();
Objects.requireNonNull(objectInstance, "null cannot be cast to non-null type com.discord.api.auth.OAuthScope");
OAuthScope oAuthScope = (OAuthScope) objectInstance;
hashMap.put(oAuthScope.a(), oAuthScope);
}
}
nameToScopeMap = hashMap;
}
public static final /* synthetic */ HashMap a() {
return nameToScopeMap;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // com.google.gson.TypeAdapter
public OAuthScope read(JsonReader jsonReader) {
m.checkNotNullParameter(jsonReader, "in");
if (jsonReader.N() == JsonToken.NULL) {
jsonReader.H();
return null;
}
String K = jsonReader.K();
OAuthScope oAuthScope = nameToScopeMap.get(K);
if (oAuthScope == null) {
m.checkNotNullExpressionValue(K, "scopeName");
oAuthScope = new OAuthScope.Invalid(K);
}
return oAuthScope;
}
/* 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, OAuthScope oAuthScope) {
OAuthScope oAuthScope2 = oAuthScope;
m.checkNotNullParameter(jsonWriter, "out");
if (oAuthScope2 != null) {
jsonWriter.H(oAuthScope2.a());
} else {
jsonWriter.s();
}
}
}