Exemplo n.º 1
0
 public static void addGetterSetterCallBean(
     TypeWrapper type, MethodSpec.Builder mapFieldsBuilder, String getterName) {
   ClassName nestedParser = ClassName.get(packageName, type.getName() + classNameSufix);
   mapFieldsBuilder
       .beginControlFlow(
           "if ("
               + instanceName
               + " != null && "
               + instanceName
               + "."
               + getterName
               + "() != null)")
       .addStatement(
           stringBuilderName
               + ".append($T."
               + parseFieldsFunction
               + "("
               + instanceName
               + "."
               + getterName
               + "()))",
           nestedParser)
       .endControlFlow()
       .beginControlFlow("else")
       .addStatement(
           stringBuilderName + ".append($T." + parseFieldsFunction + "(null))", nestedParser)
       .endControlFlow();
 }
Exemplo n.º 2
0
  public static MethodSpec.Builder createParseFieldsToListFunction(
      TypeWrapper type, MethodSpec.Builder mapFieldsBuilder, String getterName, int length) {
    ClassName nestedParser = ClassName.get(packageName, type.getName() + classNameSufix);
    mapFieldsBuilder
        .beginControlFlow("for (int i = 0; i < " + String.valueOf(length) + "; i++)")
        .beginControlFlow(
            "if ("
                + instanceName
                + " != null && "
                + instanceName
                + "."
                + getterName
                + "() != null && "
                + instanceName
                + "."
                + getterName
                + "().size() > i)")
        .addStatement(
            stringBuilderName
                + ".append($T."
                + parseFieldsFunction
                + "("
                + instanceName
                + "."
                + getterName
                + "().get(i)))",
            nestedParser)
        .endControlFlow()
        .beginControlFlow("else")
        .addStatement(
            stringBuilderName + ".append($T." + parseFieldsFunction + "(null))", nestedParser)
        .endControlFlow()
        .endControlFlow();

    return mapFieldsBuilder;
  }