本文整理了Java中retrofit2.Retrofit.nextRequestBodyConverter
方法的一些代码示例,展示了Retrofit.nextRequestBodyConverter
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Retrofit.nextRequestBodyConverter
方法的具体详情如下:
包路径:retrofit2.Retrofit
类名称:Retrofit
方法名:nextRequestBodyConverter
[英]Returns a Converter for type to RequestBody from the available #converterFactories() except skipPast.
[中]从可用的#ConverterFactorys()将类型的转换器返回到RequestBody,SkippCast除外。
代码示例来源:origin: square/retrofit
/**
* Returns a {@link Converter} for {@code type} to {@link RequestBody} from the available
* {@linkplain #converterFactories() factories}.
*
* @throws IllegalArgumentException if no converter available for {@code type}.
*/
public <T> Converter<T, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations) {
return nextRequestBodyConverter(null, type, parameterAnnotations, methodAnnotations);
}
代码示例来源:origin: com.squareup.retrofit2/retrofit
/**
* Returns a {@link Converter} for {@code type} to {@link RequestBody} from the available
* {@linkplain #converterFactories() factories}.
*
* @throws IllegalArgumentException if no converter available for {@code type}.
*/
public <T> Converter<T, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations) {
return nextRequestBodyConverter(null, type, parameterAnnotations, methodAnnotations);
}
代码示例来源:origin: square/retrofit
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
boolean isBody = false;
boolean isChunked = false;
for (Annotation annotation : parameterAnnotations) {
isBody |= annotation instanceof Body;
isChunked |= annotation instanceof Chunked;
}
if (!isBody || !isChunked) {
return null;
}
// Look up the real converter to delegate to.
final Converter<Object, RequestBody> delegate =
retrofit.nextRequestBodyConverter(this, type, parameterAnnotations, methodAnnotations);
// Wrap it in a Converter which removes the content length from the delegate's body.
return new Converter<Object, RequestBody>() {
@Override public RequestBody convert(Object value) throws IOException {
final RequestBody realBody = delegate.convert(value);
return new RequestBody() {
@Override public MediaType contentType() {
return realBody.contentType();
}
@Override public void writeTo(BufferedSink sink) throws IOException {
realBody.writeTo(sink);
}
};
}
};
}
}
代码示例来源:origin: matrix-org/matrix-android-sdk
@Override
public RequestBody convert(T value) throws IOException {
Class<?> cls = value.getClass();
Converter<T, RequestBody> requestBodyConverter;
synchronized (cache) {
requestBodyConverter = cache.get(cls);
}
if (requestBodyConverter == null) {
requestBodyConverter = retrofit.nextRequestBodyConverter(
skipPast, cls, parameterAnnotations, methodsAnnotations
);
synchronized (cache) {
cache.put(cls, requestBodyConverter);
}
}
return requestBodyConverter.convert(value);
}
}
代码示例来源:origin: segmentio/retrofit-jsonrpc
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] annotations,
Annotation[] methodAnnotations, Retrofit retrofit) {
JsonRPC methodAnnotation = Utils.findAnnotation(methodAnnotations, JsonRPC.class);
if (methodAnnotation == null) {
return null;
}
String method = methodAnnotation.value();
Converter<JsonRPCRequest, RequestBody> delegate =
retrofit.nextRequestBodyConverter(this, JsonRPCRequest.class, annotations,
methodAnnotations);
//noinspection unchecked
return new JsonRPCRequestBodyConverter(method, delegate);
}
内容来源于网络,如有侵权,请联系作者删除!