예제 #1
0
  @Override
  public void generateContentValuesBuilderMethod(
      TypeSpec.Builder builder, TypeName type, String contentValuesVarName) {

    builder.addMethod(
        MethodSpec.methodBuilder(field.getFieldName())
            .addJavadoc("Adds the given value to this ContentValues\n")
            .addJavadoc("@param value The value\n")
            .addJavadoc("@return $T\n", type)
            .addModifiers(Modifier.PUBLIC)
            .addParameter(TypeName.get(field.getField().asType()), "value", Modifier.FINAL)
            .returns(type)
            .addStatement("$L.put($S, value)", contentValuesVarName, field.getColumnName())
            .addStatement("return this")
            .build());

    builder.addMethod(
        MethodSpec.methodBuilder(field.getFieldName() + "AsNull")
            .addJavadoc("Adds a null value to this ContentValues\n")
            .addJavadoc("@return $T\n", type)
            .addModifiers(Modifier.PUBLIC)
            .returns(type)
            .addStatement("$L.putNull( $S )", contentValuesVarName, field.getColumnName())
            .addStatement("return this")
            .build());
  }
예제 #2
0
 @Override
 public void generateAssignStatement(
     MethodSpec.Builder builder, String objectVarName, String cursorVarName, String indexVarName) {
   builder.addStatement(
       "$L.$L = $L.$L($L)",
       objectVarName,
       field.getFieldName(),
       cursorVarName,
       cursorMethodName,
       indexVarName);
 }