41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
|
package retrofit2;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import java.lang.annotation.Annotation;
|
||
|
import java.lang.reflect.ParameterizedType;
|
||
|
import java.lang.reflect.Type;
|
||
|
import java.util.Optional;
|
||
|
import okhttp3.ResponseBody;
|
||
|
import retrofit2.Converter;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class OptionalConverterFactory extends Converter.Factory {
|
||
|
static final Converter.Factory INSTANCE = new OptionalConverterFactory();
|
||
|
|
||
|
OptionalConverterFactory() {
|
||
|
}
|
||
|
|
||
|
@Override // retrofit2.Converter.Factory
|
||
|
public final Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotationArr, Retrofit retrofit) {
|
||
|
if (getRawType(type) != Optional.class) {
|
||
|
return null;
|
||
|
}
|
||
|
return new OptionalConverter(retrofit.responseBodyConverter(getParameterUpperBound(0, (ParameterizedType) type), annotationArr));
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class OptionalConverter<T> implements Converter<ResponseBody, Optional<T>> {
|
||
|
final Converter<ResponseBody, T> delegate;
|
||
|
|
||
|
OptionalConverter(Converter<ResponseBody, T> converter) {
|
||
|
this.delegate = converter;
|
||
|
}
|
||
|
|
||
|
@Override // retrofit2.Converter
|
||
|
public final Optional<T> convert(ResponseBody responseBody) throws IOException {
|
||
|
return Optional.ofNullable(this.delegate.convert(responseBody));
|
||
|
}
|
||
|
}
|
||
|
}
|