what-the-bank/sources/retrofit2/converter/gson/GsonRequestBodyConverter.java

42 lines
1.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package retrofit2.converter.gson;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import o.C15111ghZ;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Converter;
/* loaded from: classes.dex */
final class GsonRequestBodyConverter<T> implements Converter<T, RequestBody> {
private static final MediaType MEDIA_TYPE = MediaType.get("application/json; charset=UTF-8");
private static final Charset UTF_8 = Charset.forName("UTF-8");
private final TypeAdapter<T> adapter;
private final Gson gson;
/* JADX WARN: Multi-variable type inference failed */
@Override // retrofit2.Converter
public final /* bridge */ /* synthetic */ RequestBody convert(Object obj) throws IOException {
return convert((GsonRequestBodyConverter<T>) obj);
}
/* JADX INFO: Access modifiers changed from: package-private */
public GsonRequestBodyConverter(Gson gson, TypeAdapter<T> typeAdapter) {
this.gson = gson;
this.adapter = typeAdapter;
}
@Override // retrofit2.Converter
public final RequestBody convert(T t) throws IOException {
C15111ghZ c15111ghZ = new C15111ghZ();
JsonWriter newJsonWriter = this.gson.newJsonWriter(new OutputStreamWriter(new C15111ghZ.Sts(c15111ghZ), UTF_8));
this.adapter.write(newJsonWriter, t);
newJsonWriter.close();
return RequestBody.create(MEDIA_TYPE, c15111ghZ.c(c15111ghZ.c));
}
}