Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
edward3h committed Sep 17, 2024
1 parent 9fd8e3c commit b178ae7
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.karuslabs.utilitary.Logger;
import com.palantir.javapoet.*;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
Expand Down Expand Up @@ -89,7 +88,8 @@ private CodeBlock queryMethodBody(DAOMethodInfo methodInfo) {
methodInfo.parameterMapping().forEach(parameterInfo -> {
var name = "param" + parameterInfo.index();
var conversion = lookupConversion(parameterInfo::element, parameterInfo.mapper());
buildConversion(builder, conversion, parameterInfo.mapper().target(), name, parameterInfo.javaAccessor(), true);
buildConversion(
builder, conversion, parameterInfo.mapper().target(), name, parameterInfo.javaAccessor(), true);
var nullableSource = parameterInfo.mapper().source().isNullable();
// if (nullableSource) {
// builder.beginControlFlow("if ($L == null)", name)
Expand Down Expand Up @@ -122,7 +122,8 @@ private CodeBlock queryMethodBody(DAOMethodInfo methodInfo) {
String rawName = daoResultColumn.name() + "Raw";
builder.addStatement(
"$T $L = rs.get$L($S)",
kiwiTypeConverter.fromKiwiType(daoResultColumn.sqlTypeMapping().kiwiType()),
kiwiTypeConverter.fromKiwiType(
daoResultColumn.sqlTypeMapping().kiwiType()),
rawName,
daoResultColumn.sqlTypeMapping().accessorSuffix(),
daoResultColumn.name());
Expand All @@ -132,7 +133,8 @@ private CodeBlock queryMethodBody(DAOMethodInfo methodInfo) {
.endControlFlow();
}
var varName = patchName(daoResultColumn.name());
buildConversion(builder, conversion, daoResultColumn.asTypeMapping().target(), varName, rawName, true);
buildConversion(
builder, conversion, daoResultColumn.asTypeMapping().target(), varName, rawName, true);
});
var params = multipleColumns.stream()
.map(p -> CodeBlock.of("$L", patchedNames.get(p.name())))
Expand Down Expand Up @@ -163,7 +165,12 @@ private CodeBlock queryMethodBody(DAOMethodInfo methodInfo) {
}

private void buildConversion(
CodeBlock.Builder builder, Conversion conversion, KiwiType targetType, String assignee, String accessor, boolean withVar) {
CodeBlock.Builder builder,
Conversion conversion,
KiwiType targetType,
String assignee,
String accessor,
boolean withVar) {
var insertVar = withVar ? "var " : "";
if (conversion instanceof AssignmentConversion) {
/* e.g.
Expand Down Expand Up @@ -238,7 +245,7 @@ private void buildConversion(
} else if (conversion instanceof NullableSourceConversion nsc) {
builder.addStatement("$T $L = null", kiwiTypeConverter.fromKiwiType(targetType), assignee)
.beginControlFlow("if ($L != null)", accessor);
buildConversion(builder, nsc.conversion(), targetType,assignee, accessor, false);
buildConversion(builder, nsc.conversion(), targetType, assignee, accessor, false);
builder.endControlFlow();
} else {
logger.error(null, "Unsupported Conversion %s".formatted(conversion)); // TODO add Element
Expand Down

0 comments on commit b178ae7

Please sign in to comment.