Search in sources :

Example 1 with MethodInfo

use of com.airbnb.epoxy.ClassToGenerateInfo.MethodInfo in project epoxy by airbnb.

the class EpoxyProcessor method generateMethodsReturningClassType.

private Iterable<MethodSpec> generateMethodsReturningClassType(ClassToGenerateInfo info) {
    List<MethodSpec> methods = new ArrayList<>(info.getMethodsReturningClassType().size());
    for (MethodInfo methodInfo : info.getMethodsReturningClassType()) {
        Builder builder = MethodSpec.methodBuilder(methodInfo.name).addModifiers(methodInfo.modifiers).addParameters(methodInfo.params).addAnnotation(Override.class).varargs(methodInfo.varargs).returns(info.getParameterizedGeneratedName());
        StringBuilder statementBuilder = new StringBuilder(String.format("super.%s(", methodInfo.name));
        generateParams(statementBuilder, methodInfo.params);
        methods.add(builder.addStatement(statementBuilder.toString()).addStatement("return this").build());
    }
    return methods;
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) Builder(com.squareup.javapoet.MethodSpec.Builder) ArrayList(java.util.ArrayList) MethodInfo(com.airbnb.epoxy.ClassToGenerateInfo.MethodInfo)

Aggregations

MethodInfo (com.airbnb.epoxy.ClassToGenerateInfo.MethodInfo)1 MethodSpec (com.squareup.javapoet.MethodSpec)1 Builder (com.squareup.javapoet.MethodSpec.Builder)1 ArrayList (java.util.ArrayList)1