/**
* Generates a particular method with an equivalent name and arguments to the given method
* from the generated {@link com.bumptech.glide.request.BaseRequestBuilder} subclass.
*/
private MethodSpec generateGeneratedRequestOptionEquivalent(MethodSpec requestOptionMethod) {
CodeBlock callRequestOptionsMethod = CodeBlock.builder()
.add(".$N(", requestOptionMethod.name)
.add(FluentIterable.from(requestOptionMethod.parameters)
.transform(new Function<ParameterSpec, String>() {
@Override
public String apply(ParameterSpec input) {
return input.name;
}
})
.join(Joiner.on(", ")))
.add(");\n")
.build();
return MethodSpec.methodBuilder(requestOptionMethod.name)
.addJavadoc(
processorUtil.generateSeeMethodJavadoc(requestOptionsClassName, requestOptionMethod))
.addModifiers(Modifier.PUBLIC)
.addTypeVariables(requestOptionMethod.typeVariables)
.addParameters(requestOptionMethod.parameters)
.returns(generatedRequestBuilderOfTranscodeType)
.beginControlFlow(
"if (getMutableOptions() instanceof $T)", requestOptionsClassName)
.addCode("this.requestOptions = (($T) getMutableOptions())",
requestOptionsClassName)
.addCode(callRequestOptionsMethod)
.nextControlFlow("else")
.addCode(CodeBlock.of("this.requestOptions = new $T().apply(this.requestOptions)",
requestOptionsClassName))
.addCode(callRequestOptionsMethod)
.endControlFlow()
.addStatement("return this")
.build();
}
RequestBuilderGenerator.java 文件源码
java
阅读 42
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录