lombok.experimental.Builder Java Examples
The following examples show how to use
lombok.experimental.Builder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addCallToComplexColumnsPersistIgnoringNullIfNeeded(MethodSpec.Builder builder) { final TableElement tableElement = entityEnvironment.getTableElement(); if (tableElement.hasAnyPersistedComplexColumns()) { final CodeBlock.Builder statementBuilder = CodeBlock.builder(); if (tableElement.hasAnyPersistedImmutableComplexColumns()) { statementBuilder.add("final long[] ids = "); } statementBuilder.add("$T.$L($L, $L, $L.getDbConnection(), $L, $L)", entityEnvironment.getDaoClassName(), METHOD_CALL_INTERNAL_PERSIST_IGNORING_NULL_VALUES_ON_COMPLEX_COLUMNS, ENTITY_VARIABLE, "values", MANAGER_VARIABLE, OPERATION_HELPER_VARIABLE, OPERATION_BY_COLUMNS_VARIABLE); statementBuilder.add(codeBlockEnd()); builder.addCode(statementBuilder.build()); } }
Example #2
Source File: InsertWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private MethodSpec bindToInsertStatement() { MethodSpec.Builder builder = MethodSpec.methodBuilder(METHOD_BIND_TO_INSERT_STATEMENT) .addModifiers(STATIC_METHOD_MODIFIERS) .addParameter(SUPPORT_SQLITE_STATEMENT, "statement") .addParameter(entityParameter(tableElementTypeName)) .addStatement("statement.clearBindings()"); addImmutableIdsParameterIfNeeded(builder, tableElement); int colPos = 1; int immutableIdColPos = 0; for (ColumnElement columnElement : tableElement.getAllColumns()) { if (columnElement.isId() && columnElement.isAutoincrementId()) { continue; } if (columnElement.isHandledRecursively() && columnElement.isReferencedTableImmutable()) { addBindColumnFromProvidedIdsBlock(builder, columnElement, colPos, immutableIdColPos); immutableIdColPos++; } else { addBindColumnToStatementBlock(builder, colPos, columnElement); } colPos++; } return builder.build(); }
Example #3
Source File: UpdateWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private MethodSpec bindToUpdateStatementWithComplexColumns() { final MethodSpec.Builder builder = MethodSpec.methodBuilder(METHOD_BIND_TO_UPDATE_STATEMENT_WITH_COMPLEX_COLUMNS) .addModifiers(STATIC_METHOD_MODIFIERS) .addParameter(SUPPORT_SQLITE_STATEMENT, "statement") .addParameter(tableElementTypeName, ENTITY_VARIABLE) .addStatement("statement.clearBindings()"); addImmutableIdsParameterIfNeeded(builder, tableElement); int colPos = 1; int immutableIdColPos = 0; for (ColumnElement columnElement : tableElement.getColumnsExceptId()) { if (columnElement.isHandledRecursively() && columnElement.isReferencedTableImmutable()) { addBindColumnFromProvidedIdsBlock(builder, columnElement, colPos, immutableIdColPos); immutableIdColPos++; } else { addBindColumnToStatementBlock(builder, colPos, columnElement); } colPos++; } return builder.build(); }
Example #4
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addMutableTableComplexColumnRetrieveFromSelection(CodeBlock.Builder builder, String complexMethodName, String offsetString, ColumnElement columnElement, String... args) { final FormatData settableValue = callToComplexColumnRetrieve(complexMethodName, columnElement, args); final String tmpVariableName = columnElement.getElementName(); final TableElement referencedTable = columnElement.getReferencedTable(); builder.addStatement(settableValue.formatInto("final $T $L = %s"), settableValue .getWithOtherArgsBefore( referencedTable.getTableElementTypeName(), tmpVariableName)) .beginControlFlow("if ($L != null)", tmpVariableName); FormatData deserializedValueSetter = columnElement.deserializedValueSetter(ENTITY_VARIABLE, tmpVariableName, MANAGER_VARIABLE); builder.addStatement(deserializedValueSetter.getFormat(), deserializedValueSetter.getArgs()) .nextControlFlow("else"); if (!referencedTable.canBeInstantiatedWithOnlyId()) { builder.addStatement("throw new $T(\"Complex column $L cannot be instantiated with only id\")", SQL_EXCEPTION, columnElement.getElementName()); } else { addMutableTableComplexColumnWithOnlyIdForRetrieveFromPosition(builder, columnElement, offsetString); } builder.endControlFlow(); builder.endControlFlow(); // ends outer if addSelectAllFromTableNextControlFlowCheck(builder, columnElement); addMutableTableComplexColumnRetrieve(builder, complexMethodName, columnElement, args); }
Example #5
Source File: UpdateWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addBulkUpdateNormalLoopBody(MethodSpec.Builder builder) { addNullableIdCheckIfNeeded(builder); addBindToUpdateStatement(builder); if (tableElement.hasAnyPersistedComplexColumns()) { builder.beginControlFlow("if ($L.executeUpdateDelete() <= 0 || !$T.$L($L, $L.getDbConnection(), $L, $L))", STATEMENT_VARIABLE, daoClassName, METHOD_CALL_INTERNAL_UPDATE_ON_COMPLEX_COLUMNS, ENTITY_VARIABLE, MANAGER_VARIABLE, OPERATION_HELPER_VARIABLE, OPERATION_BY_COLUMNS_VARIABLE); } else { builder.beginControlFlow("if ($L.executeUpdateDelete() <= 0)", STATEMENT_VARIABLE) .beginControlFlow("if (!$L.ignoreConflict)", OPERATION_HELPER_VARIABLE); } addThrowOperationFailedExceptionWithEntityVariable(builder, FAILED_TO_UPDATE_ERR_MSG); builder.endControlFlow(); if (!tableElement.hasAnyPersistedComplexColumns()) { builder.nextControlFlow("else") .addStatement("atLeastOneSuccess = true") .endControlFlow(); } }
Example #6
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void buildForMutableObject() { if (tableElement == null) { throw new IllegalStateException("Cannot build for mutable object when table element is missing"); } forAllBuilders(addMutableTableNewInstanceVariable()); final List<ColumnElement> allColumns = tableElement.getAllColumns(); for (int i = 0, columnsCount = allColumns.size(); i < columnsCount; i++) { final ColumnElement columnElement = allColumns.get(i); buildForAllValuesRetrievingMutableObject(columnElement, i, columnsCount); buildForSelectionValuesRetrievingMutableObject(columnElement); } forAllBuilders(new Callback<CodeBlock.Builder>() { @Override public void call(CodeBlock.Builder builder) { builder.addStatement("return $L", ENTITY_VARIABLE); } }); }
Example #7
Source File: InsertWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private MethodSpec internalInsert() { final MethodSpec.Builder builder = MethodSpec.methodBuilder(METHOD_INTERNAL_INSERT) .addModifiers(STATIC_METHOD_MODIFIERS) .addParameter(entityParameter(tableElementTypeName)) .addParameter(entityDbManagerParameter()) .addParameter(operationHelperParameter()) .returns(LONG); addCallToInternalInsertOnComplexColumnsIfNeeded(entityEnvironment, builder); addInsertLoggingStatement(builder, tableElement); builder.addStatement("final long id") .addCode(insertStatementVariableFromOpHelper(tableElement, STATEMENT_VARIABLE)) .beginControlFlow("synchronized ($L)", STATEMENT_VARIABLE); addBindToInsertStatement(builder, tableElement, daoClassName, STATEMENT_VARIABLE); builder.addStatement("id = $L.executeInsert()", STATEMENT_VARIABLE) .endControlFlow(); addAfterInsertLoggingStatement(builder); addCheckIdValidity(builder, FAILED_TO_INSERT_ERR_MSG); addSetIdStatementIfNeeded(tableElement, daoClassName, builder); return builder .addStatement("return id") .build(); }
Example #8
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 6 votes |
static void addSimpleSelectionCheck(CodeBlock.Builder builder, CodeBlock.Builder preCodeBuilder, String parentTableName, BaseColumnElement columnElement, String offsetString, boolean forBuilder, boolean fromSelection) { if (fromSelection) { if (forBuilder) { if (columnElement.isNullable()) { builder.beginControlFlow("if ($1L != null && !cursor.isNull($1L))", offsetString); } else if (columnElement.hasNullableAnnotation()) { builder.beginControlFlow("if ($1L != null)", offsetString); } else { addColumnMissingFromSelectionException(builder, columnElement, offsetString, parentTableName); } } else { if (!columnElement.isNullable()) { addColumnMissingFromSelectionException(preCodeBuilder, columnElement, offsetString, parentTableName); } } } }
Example #9
Source File: UpdateWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addBulkUpdateComplexColumnIgnoreConflictLoopBody(MethodSpec.Builder builder) { builder.addStatement("final $T $L = $L.newTransaction()", TRANSACTION, TRANSACTION_VARIABLE, DB_CONNECTION_VARIABLE) .beginControlFlow("try"); addNullableIdCheckIfNeeded(builder); addBindToUpdateStatement(builder); builder.beginControlFlow("if ($L.executeUpdateDelete() > 0 && $T.$L($L, $L.getDbConnection(), $L, $L))", STATEMENT_VARIABLE, daoClassName, METHOD_CALL_INTERNAL_UPDATE_ON_COMPLEX_COLUMNS, ENTITY_VARIABLE, MANAGER_VARIABLE, OPERATION_HELPER_VARIABLE, OPERATION_BY_COLUMNS_VARIABLE) .addStatement("$L.markSuccessful()", TRANSACTION_VARIABLE) .addStatement("atLeastOneSuccess = true") .endControlFlow() .nextControlFlow("catch ($T e)", OPERATION_FAILED_EXCEPTION) .addStatement("continue") .nextControlFlow("finally") .addStatement("$L.end()", TRANSACTION_VARIABLE) .endControlFlow(); }
Example #10
Source File: InsertWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addBulkInsertComplexColumnIgnoreConflictLoopBody(MethodSpec.Builder builder) { builder.addStatement("final $T $L = $L.newTransaction()", TRANSACTION, TRANSACTION_VARIABLE, DB_CONNECTION_VARIABLE) .beginControlFlow("try"); addCallToInternalInsertOnComplexColumnsIfNeeded(entityEnvironment, builder); addBindToInsertStatement(builder, tableElement, daoClassName, STATEMENT_VARIABLE); builder.addStatement("final long id = $L.executeInsert()", STATEMENT_VARIABLE); addAfterInsertLoggingStatement(builder); builder.beginControlFlow("if (id != -1)"); addSetIdStatementIfNeeded(tableElement, daoClassName, builder); builder.addStatement("$L.markSuccessful()", TRANSACTION_VARIABLE) .addStatement("atLeastOneSuccess = true") .endControlFlow() .nextControlFlow("catch ($T e)", OPERATION_FAILED_EXCEPTION) .addStatement("continue") .nextControlFlow("finally") .addStatement("$L.end()", TRANSACTION_VARIABLE) .endControlFlow(); }
Example #11
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private void addBulkPersistExecuteForFixedColumns(MethodSpec.Builder builder) { addBulkPersistTopBlockForFixedColumns(builder, true); if (tableElement.hasAnyPersistedComplexColumns()) { ModelPersistingGenerator.addTransactionEndBlock(builder, allTableTriggers, "return true", "return false", true); builder.endControlFlow(); // .ignoreConflict } else { ModelPersistingGenerator.addTransactionEndBlock(builder, allTableTriggers, CodeBlock.builder() .addStatement("success = atLeastOneSuccess") .build(), CodeBlock.builder() .addStatement("return atLeastOneSuccess") .build(), "return false", true); } }
Example #12
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 6 votes |
private MethodSpec bulkPersistExecute() { final MethodSpec.Builder builder = MethodSpec.methodBuilder(METHOD_EXECUTE) .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC) .returns(TypeName.BOOLEAN) .addCode(entityDbVariablesForOperationBuilder(tableElement)); addIgnoreNullValuesControlFlowStart(builder); addBulkPersistExecuteForNullableColumns(builder); builder.nextControlFlow("else"); addBulkPersistExecuteForFixedColumns(builder); builder.endControlFlow(); return builder.build(); }
Example #13
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addMutableComplexColumnRetrieve(CodeBlock.Builder builder, CodeBlock.Builder fromAllSelectionBuilder, String complexMethodName, ColumnElement columnElement) { addMutableTableComplexColumnRetrieve(builder, complexMethodName, columnElement, complexColumnRetrieveParams); if (columnElement.isNullable()) { builder.nextControlFlow("else") .add(columnOffsetCorrectionStatement(columnElement, complexMethodName)); } addMutableTableComplexColumnRetrieve(fromAllSelectionBuilder, complexMethodName, columnElement, complexColumnRetrieveFromSelectionParams(columnElement, ImmutableObjectBuilderMetadata.DEFAULT)); }
Example #14
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addBulkPersistLoopWithCompiledStatements(MethodSpec.Builder builder, Callback<MethodSpec.Builder> body) { builder .beginControlFlow("synchronized ($L)", UPDATE_STATEMENT_VARIABLE) .beginControlFlow("synchronized ($L)", INSERT_STATEMENT_VARIABLE) .beginControlFlow("for ($T $L : $L)", tableElementTypeName, ENTITY_VARIABLE, OBJECTS_VARIABLE); addPersistLoggingStatement(builder); body.call(builder); builder .endControlFlow() .endControlFlow() .endControlFlow(); }
Example #15
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addBulkPersistExecuteMainBody(MethodSpec.Builder builder, Callback<MethodSpec.Builder> insertValidityCheck) { final boolean idColumnNullable = tableElement.getIdColumn().isNullable(); final boolean hasUniqueColumnsOtherThanId = tableElement.hasUniqueColumnsOtherThanId(); final boolean anyUniqueColumnNullable = tableElement.isAnyUniqueColumnNullable(); addCallToComplexColumnsPersistIfNeeded(builder); if (idColumnNullable) { builder.addStatement("int rowsAffected = 0"); if (!hasUniqueColumnsOtherThanId) { builder.addCode(entityEnvironment.getIdVariable()) .beginControlFlow("if (id != null)"); } else if (anyUniqueColumnNullable) { builder.beginControlFlow("if (!$T.$L($L, $L))", daoClassName, METHOD_IS_UNIQUE_COLUMN_NULL, UPDATE_BY_COLUMN_VARIABLE, ENTITY_VARIABLE); } } addBindToUpdateStatement(builder, UPDATE_STATEMENT_VARIABLE, "id", hasUniqueColumnsOtherThanId); if (idColumnNullable) { builder.addStatement("rowsAffected = $L.executeUpdateDelete()", UPDATE_STATEMENT_VARIABLE) .endControlFlow() .beginControlFlow("if (rowsAffected <= 0)"); } else { builder.beginControlFlow("if ($L.executeUpdateDelete() <= 0)", UPDATE_STATEMENT_VARIABLE); } addPersistUpdateFailedLoggingStatement(builder); addBindToInsertStatement(builder, tableElement, daoClassName, INSERT_STATEMENT_VARIABLE); if (idColumnNullable && !hasUniqueColumnsOtherThanId) { builder.addStatement("id = $L.executeInsert()", INSERT_STATEMENT_VARIABLE); } else { builder.addStatement("final $T id = $L.executeInsert()", LONG, INSERT_STATEMENT_VARIABLE); } addAfterInsertLoggingStatement(builder); insertValidityCheck.call(builder); builder.endControlFlow(); }
Example #16
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addMutableTableComplexColumnWithOnlyIdForRetrieveFromPosition(CodeBlock.Builder builder, ColumnElement columnElement, String offsetString) { final TableElement referencedTable = columnElement.getReferencedTable(); final String settableValue = columnElement.cursorGetter("cursor", offsetString); final FormatData complexColumnNewInstanceCall = complexColumnNewInstanceWithOnlyIdCall(settableValue, referencedTable); final FormatData deserializedValueSetter = columnElement.deserializedValueSetter( ENTITY_VARIABLE, complexColumnNewInstanceCall.getFormat(), MANAGER_VARIABLE ); builder.addStatement(deserializedValueSetter.getFormat(), deserializedValueSetter.getWithOtherArgsAfter(complexColumnNewInstanceCall.getArgs())); }
Example #17
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addFromSelectionAddCheck(CodeBlock.Builder builder, ColumnElement columnElement) { if (columnElement.isHandledRecursively()) { builder.beginControlFlow("if (pos != null)"); } else { builder.beginControlFlow("if (pos != null && !cursor.isNull(pos))"); } }
Example #18
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void buildForSelectionValuesRetrievingMutableObject(ColumnElement columnElement) { final String offsetString = "pos"; CodeBlock.Builder commonCodeBuilder = CodeBlock.builder() .add(assignFromSelectionPositionGetterToPos(columnElement, ImmutableObjectBuilderMetadata.DEFAULT)); addFromSelectionAddCheck(commonCodeBuilder, columnElement); if (columnElement.isReferencedColumn()) { if (columnElement.isHandledRecursively()) { commonCodeBuilder.beginControlFlow("if (!cursor.isNull(pos))"); commonCodeBuilder = flushCommonCodeTo(fromSelectionRetrievingBuilders, commonCodeBuilder); final String[] complexCallParams = complexColumnRetrieveFromSelectionParams(columnElement, ImmutableObjectBuilderMetadata.DEFAULT); // shallow if (columnElement.isNeededForShallowQuery()) { addMutableTableComplexColumnRetrieveFromSelection(shallowObjectFromSelectionBuilder, METHOD_SHALLOW_OBJECT_FROM_CURSOR_POSITION, offsetString, columnElement, complexCallParams); } else { addMutableTableComplexColumnWithOnlyIdForRetrieveFromPosition(shallowObjectFromSelectionBuilder, columnElement, offsetString); shallowObjectFromSelectionBuilder.endControlFlow(); } // deep addMutableTableComplexColumnRetrieveFromSelection(fullObjectFromSelectionBuilder, METHOD_FULL_OBJECT_FROM_CURSOR_POSITION, offsetString, columnElement, complexCallParams); } else { addMutableTableComplexColumnWithOnlyIdForRetrieveFromPosition(commonCodeBuilder, columnElement, offsetString); } } else { addMutableTableSimpleColumnSetter(commonCodeBuilder, columnElement, offsetString); } commonCodeBuilder.endControlFlow(); addCommonCodeTo(fromSelectionRetrievingBuilders, commonCodeBuilder); }
Example #19
Source File: RetrieveWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
static void addValuesGatheringBlock(MethodSpec.Builder builder, boolean addDeepQuery, Callback<MethodSpec.Builder> deepBuilderCallback, Callback<MethodSpec.Builder> shallowBuilderCallback) { if (addDeepQuery) { builder.beginControlFlow("if (queryDeep)"); deepBuilderCallback.call(builder); builder.nextControlFlow("else"); } shallowBuilderCallback.call(builder); if (addDeepQuery) { builder.endControlFlow(); } }
Example #20
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addBulkPersistExecuteForNullableColumns(MethodSpec.Builder builder) { addBulkPersistTopBlockForNullableColumns(builder, true); if (tableElement.hasAnyPersistedComplexColumns()) { ModelPersistingGenerator.addTransactionEndBlock(builder, allTableTriggers, CodeBlock.builder() .addStatement("success = true") .build(), CodeBlock.builder() .addStatement("return true") .build(), "return false", false); builder.endControlFlow(); // .ignoreConflict } else { ModelPersistingGenerator.addTransactionEndBlock(builder, allTableTriggers, CodeBlock.builder() .addStatement("success = atLeastOneSuccess") .build(), CodeBlock.builder() .addStatement("return atLeastOneSuccess") .build(), "return false", false); } }
Example #21
Source File: RetrieveWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private MethodSpec objectFromCursorPositionWithSelection(String methodName, boolean shallow) { final MethodSpec.Builder builder = selectedObjectValuesFromCursorPositionMethodBuilder(methodName, tableElement.getTableElementTypeName()); if (shallow) { builder.addCode(retrieveMethodsBodyBuilder.getForShallowObjectFromSelection()); } else { builder.addCode(retrieveMethodsBodyBuilder.getForFullObjectFromSelection()); } return builder.build(); }
Example #22
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addNormalLoopBodyValidityCheck(MethodSpec.Builder builder) { if (tableElement.hasAnyPersistedComplexColumns()) { addCheckIdValidity(builder, FAILED_TO_PERSIST_ERR_MSG); addSetIdStatementIfNeeded(tableElement, daoClassName, builder); } else { addIdValidityRespectingConflictAbort(builder, tableElement, daoClassName, FAILED_TO_PERSIST_ERR_MSG); builder .nextControlFlow("else") .addStatement("atLeastOneSuccess = true"); } }
Example #23
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private Callback<CodeBlock.Builder> addMutableTableNewInstanceVariable() { return new Callback<CodeBlock.Builder>() { @Override public void call(CodeBlock.Builder builder) { builder.addStatement("final $1T $2L = new $1T()", tableElementTypeName, ENTITY_VARIABLE); } }; }
Example #24
Source File: QueryCompilerWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
@NonNull public static MethodSpec.Builder queryPartsAddMethodSignature(String methodName) { return MethodSpec.methodBuilder(methodName) .returns(SYSTEM_RENAMED_TABLES_TYPE_NAME) .addParameter(fromSelectClauseParam()) .addParameter(selectFromTablesParam()) .addParameter(tableGraphNodeNamesParam()) .addParameter(select1Param()); }
Example #25
Source File: RetrieveWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private MethodSpec objectFromCursorPosition(String methodName, boolean shallow) { final MethodSpec.Builder builder = allObjectValuesFromCursorPositionMethodBuilder(methodName, tableElement.getTableElementTypeName()); if (shallow) { builder.addCode(retrieveMethodsBodyBuilder.getForShallowObject()); } else { builder.addCode(retrieveMethodsBodyBuilder.getForFullObject()); } return builder.build(); }
Example #26
Source File: InsertWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
static void addBindToInsertStatement(MethodSpec.Builder builder, TableElement tableElement, ClassName daoClassName, String insertStmVariableName) { builder.addCode(statementWithImmutableIdsIfNeeded(tableElement, "$T.$L($L, $L", daoClassName, METHOD_BIND_TO_INSERT_STATEMENT, insertStmVariableName, ENTITY_VARIABLE)); }
Example #27
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private TypeSpec bulkPersist() { final TypeName interfaceType = ENTITY_BULK_PERSIST_BUILDER; final TypeSpec.Builder builder = operationBuilderInnerClassSkeleton(entityEnvironment, CLASS_BULK_PERSIST, interfaceType, iterable, OBJECTS_VARIABLE); addConflictAlgorithmToOperationBuilder(builder, interfaceType); addOperationByColumnToOperationBuilder(builder, interfaceType); return builder .addSuperinterface(interfaceType) .addField(TypeName.BOOLEAN, IGNORE_NULL_VALUES_VARIABLE, Modifier.PRIVATE) .addMethod(setIgnoreNullValues(interfaceType)) .addMethod(bulkPersistExecute()) .addMethod(bulkPersistObserve(builder)) .build(); }
Example #28
Source File: PersistWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
private void addBindToNotNullValues(MethodSpec.Builder builder) { builder.addCode(statementWithImmutableIdsIfNeeded( tableElement, "$T.$L($L, values", daoClassName, METHOD_BIND_TO_NOT_NULL, ENTITY_VARIABLE)); }
Example #29
Source File: InsertWriter.java From sqlitemagic with Apache License 2.0 | 5 votes |
public void writeHandler(TypeSpec.Builder classBuilder) { final MethodSpec internalInsert = internalInsert(); classBuilder .addMethod(internalInsert) .addType(insert(internalInsert)) .addType(bulkInsert()); }
Example #30
Source File: RetrieveMethodsBodyBuilder.java From sqlitemagic with Apache License 2.0 | 5 votes |
private CodeBlock.Builder buildHeaderForSelection() { CodeBlock.Builder builder = CodeBlock.builder(); builder.addStatement("String thisTableName = tableGraphNodeNames.get(nodeName)") .beginControlFlow("if (thisTableName == null)") .beginControlFlow("if (nodeName.length() > 0)") .addStatement("return null") .endControlFlow() .addStatement("thisTableName = $S", tableName) .endControlFlow() .addStatement("$T pos = columns.get(thisTableName)", TypeName.INT.box()) .beginControlFlow("if (pos != null)") .addStatement("int thisTableOffset = pos"); return builder; }